Page 1 of 1

Signal Processing at high frequencies

Posted: Wed May 05, 2021 5:22 pm
by rampudia
Hi! I would like to sample data from the ADC at a frequency of ~2kHz and process it internally before logging the result at the regular 10-100Hz with the python client. I am having a hard time accommodating this functionality in the firmware with an APP or a deck driver and for this reason I would like your advice. Is this the right way to go, should I create a task or some other way?

Re: Signal Processing at high frequencies

Posted: Thu May 06, 2021 12:59 pm
by arnaud
2KHz using a task is complicated since the FreeRTOS scheduler is setup to work on a 1KHz tick, this means that sleep can only be setup in steps of 1ms and be >1ms. So the easy solution of having a loop in a task with delay is not possible. It is possible to change the tick time of the OS but this risks to break random things in the firmware.

One way forward I can think about would be to use a timer and interrups: use a timer to trigger the adc at 2KHz (either directly or from an interrupt) and from the ADC interrupt push measurement in a freertos queue, this queue can be read from your app task and the data can be processed there. To do that you will need to read the stm32F405 reference manual and to use the ST drivers directly in your app.

Re: Signal Processing at high frequencies

Posted: Thu May 06, 2021 6:28 pm
by rampudia
Ok thanks for the advice, if I succeed I will post the solution here.