Electronics > Projects, Designs, and Technical Stuff
STM 32 Streaming ADC Data continuously through UART
(1/3) > >>
Glenn0010:
Hi,

I have an STM32F302R8, an I am programming directly to the register rather than using libraries.

I have set up 2 ADC channels in 8 bit mode for continuous scanning through the DMA. I have allocated 2 8 bit spaces in memory for the ADC values to be stored in. This data will be used by the micro controller to calculate some stuff, however I'd also like to send a continuous stream of data through UART to the PC through DMA.

My dilemma is since the ADC conversion is way faster the UART (currently running at 9600), the ADC value will be overwritten before the UART transmission is complete. At this point what will happen ti the UART transmission?

A work around to this would be to take the ADC value from memory and store it in another variable until UART transmission is complete, and then load up a new one an transmit again.

Anyone has any other suggestions that might work better?

Cheers
Kalin:
I am still a beginner when it comes to these things but my first instinct would be to use interrupts to transfer the data into the UART when the transfer is complete so that it is timed to the UART rather than the ADC.
magic:
Are you worried that one byte may be corrupted in the middle of UART transmission or that two bytes will be sent by the UART from the two ADC channels, but that they will come from different moments in time?

I'm not familiar with STM32, but in general I would estimate the former as unlikely and the latter as likely. It also depends on how much built-in internal queue the UART has. Some MCUs have two bytes.
Glenn0010:

--- Quote from: Kalin on November 27, 2019, 04:58:15 pm ---I am still a beginner when it comes to these things but my first instinct would be to use interrupts to transfer the data into the UART when the transfer is complete so that it is timed to the UART rather than the ADC.

--- End quote ---
Yes that is my plan to transfer the data after a UART transfer is complete
Glenn0010:

--- Quote from: magic on November 27, 2019, 05:41:09 pm ---Are you worried that one byte may be corrupted in the middle of UART transmission or that two bytes will be sent by the UART from the two ADC channels, but that they will come from different moments in time?

I'm not familiar with STM32, but in general I would estimate the former as unlikely and the latter as likely. It also depends on how much built-in internal queue the UART has. Some MCUs have two bytes.

--- End quote ---

The latter is invetabile, since the adc is uch faster than the uart it will never be true 'real time'. However I was more worried about the data being corrupted  in the middle of uart transmission
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod