Re: 1-32khz sensor-sampling loop

Michael Hope

Hi Nathan.  I'm fairly new to Zephyr, but if you're looking for hard real time-ish at 32 kHz then I'd talk straight to the hardware.

For example, say I needed to read an ADC channel at 32 kHz on the ATSAMD21.  I'd use the Zephyr drivers to initialise the ADC and DMA units and then do custom iniitalisation that:

- Sets up a 32 kHz hardware timer
- Uses the SAM0 event system to hook the timer into the ADC trigger
- Uses the SAM0 DMA unit to read the ADC and write to memory when the ADC conversion complete event triggers

The DMA can work in ping-pong mode and fire an interrupt when the buffer is half full.  This can then set a semaphore and wake up your task.

Hope that helps,

-- Michael

On Fri, 2 Feb 2018 at 17:36 Nathan T <nathan@...> wrote:
hi all,

i'd like to sample a sensor (actually several sensors) in precise intervals at speeds up to 32khz.

it seems timer and sleep functions only have millisecond resolution and I cannot busy wait.

anyone have suggestions on the best way to go about this? 

Zephyr-users mailing list

Join to automatically receive all group messages.