ADCInput not compatible with analogRead? #3211
-
| Hello, I had success in sampling a sound wave from an analog input and then transfer it clean to an ADC (PT8211) thanks to ADCInput. I tryed the code below, but I have nothing at DAC out. Comment the Pot_Read() function in the loop and everithing works well (except for the analog read, obviously :) ) Any hint? Thanks in advance for the help! | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
| The ADC unit can be owned by either DMA or the CPU, not both. Doing analogReads while the DMA is set up is going to produce some very "interesting" results, none of which will be correct... When you use ADCInput it goes to DMA control and is set up with a HW timer that automatically samples the channels set in the bitmask w/o any intervention, stuffing their values in a FIFO for DMA to deposit to RAM. So, if you want to use another ADC input while doing ADCInput you'll just have to add that extra pin and use the ADCInput stream to look at it (i.e. 1st read() would be the mike, 2nd read() would be the pot, 3rd read() would be the mike, 4th read() the pot, etc.). | 
Beta Was this translation helpful? Give feedback.
The ADC unit can be owned by either DMA or the CPU, not both. Doing analogReads while the DMA is set up is going to produce some very "interesting" results, none of which will be correct...
When you use ADCInput it goes to DMA control and is set up with a HW timer that automatically samples the channels set in the bitmask w/o any intervention, stuffing their values in a FIFO for DMA to deposit to RAM.
So, if you want to use another ADC input while doing ADCInput you'll just have to add that extra pin and use the ADCInput stream to look at it (i.e. 1st read() would be the mike, 2nd read() would be the pot, 3rd read() would be the mike, 4th read() the pot, etc.).