Hi everyone, I am working with ESP-WROOM32 and an MCP3202 ADC (using external ADC because I need Wi-Fi and internal ADC becomes too slow then, I will be using Wi-Fi for websockets to send data).
Is it possible to use timers and/or DMA to have accurate 44.1 kHZ SPI transactions so as to have 44.1 kHz analog sampling?
Timed SPI transactions at 44.1 kHz.
-
- Posts: 1708
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: Timed SPI transactions at 44.1 kHz.
Initiating a new SPI transaction every 22us from software may be achievable, probably best with your own SPI ISR. However, doing anything in software at that (constant) rate in a multi-tasking evironment will be challenging.
Ideally, one would have the SPI clock running at, e.g. 24x 44kHz, so that each 24-bit SPI transaction takes just the right amount of time to immediately start the next one, and have the hardware take care of starting the next transaction.
The challenge here seems to be the toggling of the CS at 44kHz, i.e. convincing the hardware that a transaction ends+starts 'in the middle' of consecutive DMA data transfers. This thread addresses a very similar problem to yours.
Ideally, one would have the SPI clock running at, e.g. 24x 44kHz, so that each 24-bit SPI transaction takes just the right amount of time to immediately start the next one, and have the hardware take care of starting the next transaction.
The challenge here seems to be the toggling of the CS at 44kHz, i.e. convincing the hardware that a transaction ends+starts 'in the middle' of consecutive DMA data transfers. This thread addresses a very similar problem to yours.
Who is online
Users browsing this forum: Baidu [Spider] and 95 guests