Hi all!
I'm thinking of creating a simple datalogger that prints out the characters onto a sdcard/USB device.
I would like to be able to poll data, save it in a buffer and simultaneously write it to a txt. file. If I just choose an ordinary stm32 cortex mcu and jump back and forth between the different processes eventually either the buffer (flash memory) will run out since I can't fully write as a continuous flow is coming, or I will miss data during the write to usb/sdcard section since the MCU is busy doing that.
So I tought a dual core mcu would solve this problem. One core samples data and fills the buffer, the other core writes to usb/sdcard from the buffer.
Question is, what are the best/cheapest options available?
I've thought a lot about it, and I believe you are right. The most efficient way of doing this with a stm32 (1 core) would be to utilize DMA to reduce the number of clock cycles needed to write. I suspect this will be somewhat of a challenge, configure DMA to write to a sdcard (4gb fat32 for example) in parallel with UART gathering the characters in some buffer. In my experience the DMA overall is very complex. But that seems to be the best choice!
The easiest way is of course to poll UART (listen for an incoming message) and then send it right away to the sdcard in the same while loop. Or use interrupts and store in circular buffer and let the main loop send whenever it can. I'm just worried with interrupts that it will mess up the writing process if an incoming message happens at the same time. I'll give DMA a try before that, hopefully It can work!
Thanks for all the help, I appreciate it Andy!