Author Topic: Scanning all 18 ADC channels of Teensy 4.1 using DMA  (Read 234 times)

0 Members and 1 Guest are viewing this topic.

Offline c10yas

  • Newbie
  • Posts: 2
  • Country: us
Scanning all 18 ADC channels of Teensy 4.1 using DMA
« on: May 03, 2021, 03:08:27 am »
I'm trying to build something similar to MarcoRep's pressure-sensing matrix mat but need as high of a refresh rate as possible. I'm planning to use the Teensy 4.1 since I think I need a lot of RAM and processing power to store, process, and transmit the data to a computer using USB Serial. I could use an STM32H7 chip but the teensy4.1 seemed more accessible.

The circuit will be a 128x72 matrix. The 72 rows will be connected via a bank of 4:1 analog muxes to the 18 analog inputs of the Teensy. These analog muxes have 2 address pins to select the address, all the pins will be connected in parallel and be driven by the Teensy using a CMOS buffer. The 128 columns will be driven by a serially connected group of shift registers which will all be clocked by another Teensy output pin.

Ideally, I'd like to use ring buffers and 3 DMA channels to read the ADC data, change the analog mux positions and clock the shift register by simply writing to the GPIO pins. However, this seemed like the final goal for the project rather than step one. So step one would be to implement the analog reading, mux updating, and clocking the shifters, all in the main loop.
However, I'm stuck on step 2. This is where I want to scan all 18 ADC channels automatically and use the DMA to copy the 18 values into RAM. Then I use the CPU to copy the data from there and into my data structure, update the mux/shift registers, and finally, trigger the ADC again. How do I start going about this?

Thanks
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 1557
  • Country: us
Re: Scanning all 18 ADC channels of Teensy 4.1 using DMA
« Reply #1 on: May 04, 2021, 11:52:03 pm »
Quote
This is where I want to scan all 18 ADC channels automatically and use the DMA to copy the 18 values into RAM

My understanding of the Teensy ADCs is that there are at most two units each of which can make a reading from one of the 18 IO pins. Each ADC conversion takes some number of microseconds (like 5 or 10) to complete.

The startContinuous method will start continuous ADC readings from a single IO pin. It doesn't look like the ADC library provides a way to sequence through the IO pins automatically.

You can be notified via an interrupt when a conversion is complete. In the interrupt routine you would read and store the result of the completed conversion and have the ADC start a new conversion using the next IO pin.

The "conversionSpeed.ino" example in the ADC library has an example of using the enableInterrupts method.

https://github.com/pedvide/ADC/blob/master/examples/conversionSpeed/conversionSpeed.ino
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf