2020-10-13 10:14 AM
Hi, my application needs to handle CAN message input, Updating the screen through UART, constant buffered LOG file writing to MicroSD card. I was wondering what kind of flow I could use?
Any ideas and advises? Should I user TIMER interupt for updating screen? But I dont think that updating screen with UART in interupt is good idea as its heavy operation?
2020-10-13 11:05 AM
Can via interrupts, use circular buffer for the messages so you don't need to worry about losing data(process in main loop)
If usart is going to receive data, do that with interrupts and circular buffer aswell, then again you don't need to worry about missing something.
Transmitting could be done normally within main loop, depending on how much data needs to be sent at once.(calculate of the chunk of data you need to transmit at once takes too much time so that something might look like it's not responding).
Update the screen when you can.
Like you could use some kind of state machine.
Ie.
And then hop between those like, 1 - 4 - 2 - 4 - 3 - 4 etc. to give most time for the screen updates if that is your biggest consern.
E: and if it's still unresponsive for user actions, you could create state machines inside state machines for the code paths that take too long to finish if everyone is being done at one run.
2020-10-13 01:08 PM
i would use CMSIS RTOS v2 with FreeRTOS, This way you can add:
Very nice controlable with delays and priorities.
Cheers
2020-10-13 01:28 PM
>>But I don't think that updating screen with UART in interrupt is good idea as its heavy operation?
Buffer UART output so it is independent of the timer/interrupt.
If the operation is still too heavy, break it into bite size pieces, use a state machine/sequencer and spread it over multiple interrupts.