Hi guys,
Have been pondering for a long time, how would you prepare your code/program if you are require to do realtime/heavy computation, i.e. pooling readings from sensors, calculation, sending output, and at the same time transmit/receive massive data via UART?
The master microcontroller requires to do rapid calculation at refresh rate of 50Hz, and transmit 20-30words of each cycle. What I did earlier was to run the calculation, and then transmit the data. As my codes become longer, the idling time (per cycle) is not enough to transmit the data, even at highest baudrate possible.
The straight forward method I can think of is to use the transmit/receive hardware buffer (2 words for PIC16/18, and 4 words for dsPIC33), by filling up in batch and regularly check the buffer status, and repeat. It make my codes very messy, and the regular checking means I have to test my code every time I change it.
As my project grow, I have another microcontroller coming in and need to interface the master. The third will be connect and communicate using second UART.
Anyone has similar experience?