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?
Speed is set by the user, a config(.txt) file from the sdcard/usb is read at startup (default i'm thinking (9600 8-N-1) if nothing else is set or file cant be found, since its most common). I'll imagine different senarios, sometimes maybe i just want to log a temperature stream ,so it doesn't matter if I miss out on a few samples. But if I want to log and debug a text stream coming in or sniff data it would be best to not miss out on every 3rd word or more during the writing process. So thats what the whole dual core idea is for.
I found out the chip isn't available yet to buy, but they will be on general sale in the near future. It's a bit of shame that it has not build in flash, needs external but If it becomes much cheaper than buying the entire Pi Pico that chip+memory would certainly be an ideal choice for me! Looks to be the best course of action, else I'll guess I try with a stm32 in the meantime and see how far I can press a single core MCU with either loops or task scheduling(RTOS).
At those kind of rates, there shouldn't be any problem at all.
Looking for a micro with a FIFO on its UART and/or DMA would help.
Certainly no need for an RTOS.
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!