cancel
Showing results for 
Search instead for 
Did you mean: 

GPDMA_ADC_USART

dlagyals
Associate II

"I followed along with this video, but I have some questions. How can I correctly retrieve the ADC array values via UART communication? And why is the UART value coming out as garbage in this video?"

https://www.youtube.com/watch?v=_hX6pN2jgYM

https://rristm.github.io/tomas_materials_v2/RRISTM/stm32u5_workshop/master/2_gpdma_handson_list_mode_mx.md/17

 

I think it's a clock issue. How can I fix this?

1 ACCEPTED SOLUTION

Accepted Solutions
Dor_RH
ST Employee

Hello @dlagyals,

** How to Retrieve ADC Array Values via UART Communication:

In the mentioned video, the part discussing ADC and UART buffers is between 2:30 and 3:16 minutes.

The destination memory is a table in RAM (buffer), and transfers are done by 2 DMA channels:

  • A DMA channel transferring ADC conversion data to the buffer.
  • A DMA channel transferring buffer data to the UART Tx register.

Recommendation: Use half-buffer interrupts.

  • When the second half of the buffer is being written to, read data from the first half of the buffer: as soon as the half-buffer interrupt occurs, start the DMA transfer from the buffer (first half) to the UART.
  • Apply the same principle for the opposite halves of the buffer (first and second).

There is an example showing how to manage the buffer half-by-half in the STM32U5 FW package: ...\Projects\NUCLEO-U575ZI-Q\Examples_LL\ADC\ADC_SingleConversion_TriggerTimer_DMA_Init

** Why is the UART Value Coming Out as Garbage:

ADC conversion data are digital values depending on the analog voltage level (coded on ADC resolution from 6 to 14 bits on STM32U5).

Serial port terminals display characters coded in ASCII, which do not match the digital values.

To display ADC conversions on the terminal:

  • You need to convert the digital data to numbers in ASCII format (and even better, convert the digital data to voltage in mV. The mentioned ADC example performs this conversion).

I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.

Thanks for your contribution.

Dor_RH

View solution in original post

1 REPLY 1
Dor_RH
ST Employee

Hello @dlagyals,

** How to Retrieve ADC Array Values via UART Communication:

In the mentioned video, the part discussing ADC and UART buffers is between 2:30 and 3:16 minutes.

The destination memory is a table in RAM (buffer), and transfers are done by 2 DMA channels:

  • A DMA channel transferring ADC conversion data to the buffer.
  • A DMA channel transferring buffer data to the UART Tx register.

Recommendation: Use half-buffer interrupts.

  • When the second half of the buffer is being written to, read data from the first half of the buffer: as soon as the half-buffer interrupt occurs, start the DMA transfer from the buffer (first half) to the UART.
  • Apply the same principle for the opposite halves of the buffer (first and second).

There is an example showing how to manage the buffer half-by-half in the STM32U5 FW package: ...\Projects\NUCLEO-U575ZI-Q\Examples_LL\ADC\ADC_SingleConversion_TriggerTimer_DMA_Init

** Why is the UART Value Coming Out as Garbage:

ADC conversion data are digital values depending on the analog voltage level (coded on ADC resolution from 6 to 14 bits on STM32U5).

Serial port terminals display characters coded in ASCII, which do not match the digital values.

To display ADC conversions on the terminal:

  • You need to convert the digital data to numbers in ASCII format (and even better, convert the digital data to voltage in mV. The mentioned ADC example performs this conversion).

I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.

Thanks for your contribution.

Dor_RH