cancel
Showing results for 
Search instead for 
Did you mean: 

ADC DMA continous and FreeRTOS conflict

jmF
Associate

 

Hello,

I'm working on a NUCLEO-H743ZI2 Board.

I am attempting to record ADC samples on an SD card using a FreeRTOS CMSIS-V1 program. Below are the configurations for my ADC and Timer6:

ADC Configuration:

POSTstm1.png

Timer6 Configuration, I try to have around a 7500Hz Frequency (APB Timer Clock = 64MHz):

POSTstm2.png

 

I am acquiring a simple 30Hz sine wave generated with a Low-Frequency Signal Generator. I use HAL_ADC_ConvHalfCpltCallback() and HAL_ADC_ConvCpltCallback() to trigger a TaskNotify(). In my task, if the notification comes from HalfCplt, I write the first half of my adc_buffer (size = 10240) to the SD card. If the notification comes from Cplt, I write the second half of the adc_buffer (ping-pong mechanism).

Everything appears to work well, but there is an issue: when I examine the recorded file on my computer, I notice that some samples are missing between the first and second halves of my buffer, as seen in this screenshot:

POSTstm3.png

 

The discontinuity occurs every 5120 samples (half the size of my adc_buffer). I suspect that this may be related to a FreeRTOS priority problem.

To eliminate the possibility that the issue arises from SD writing, I attempted to write 10240 * 10 samples with a single f_write(). However, the discontinuities persist.

Interestingly, when I implement the same program without FreeRTOS, everything works perfectly, as shown in this screenshot:

POSTstm4.png

As I am still learning to implement FreeRTOS programs effectively, I am struggling to identify and resolve this problem. Your assistance in resolving this issue would be greatly appreciated!

Thanks

jm

1 ACCEPTED SOLUTION

Accepted Solutions

The topic can be closed, I was actually doing something bad in my writting on SD function.

I also found help in this post: https://community.st.com/t5/stm32-mcus-products/store-adc-s-data-stream-without-losses/td-p/315657/page/2
where it is advised to increase the buffer size to match the sector size.

Thank you,

jm

 

View solution in original post

3 REPLIES 3
Sarra.S
ST Employee

Hello @jmF

Thank you for describing the issue, could you provide a little more information about your code 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

The topic can be closed, I was actually doing something bad in my writting on SD function.

I also found help in this post: https://community.st.com/t5/stm32-mcus-products/store-adc-s-data-stream-without-losses/td-p/315657/page/2
where it is advised to increase the buffer size to match the sector size.

Thank you,

jm

 

SofLit
ST Employee

Hello,


To eliminate the possibility that the issue arises from SD writing, I attempted to write 10240 * 10 samples with a single f_write().


This statement is not clear. Do you mean that when you try to discard the SD writing and write all the buffers into the RAM you still missing that samples?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.