What means ADC0_RA

Oleum

Active member
I understand it to be an indication of the ADC.

But with my Teensy 4.1 I get the message that:
'ADC0_RA' was not declared in this scope; did you mean 'ADC1_R6'.
I want to use pin A8.
Where does the result for A8 come from in this function?

Could someone please explain this function to me?




Code:
/* the function uint16_t analogReadFastADC0(uint8_t pin)
 * is from ADC.cpp and ADC_Module.cpp, here specialised for ADC0 
 * for more speed; this one takes 2,2 us with f_CPU = 96 MHz
 */
uint16_t analogReadFastADC0(uint8_t pin){
  uint16_t result;
  
  adc->adc0->startReadFast(pin);      // start single read (with adc->adc0->singleMode(); in setup() )
  while(adc->adc0->isConverting()) {} // wait for the ADC to finish
                                      //  __disable_irq();
  result = (uint16_t)[B]ADC0_RA;[/B]
                                      //   __enable_irq();
  return result;
}
 
The comment in the code about "f_CPU = 96 MHz" suggests that it was written for the Teensy 3.x series.
The T4.1 probably doesn't have a ADC0_RA register.

Pete
 
And how can I translate this information into Teensy 4.1?

Did you try this first?

Code:
uint16_t analogReadFastADC0(uint8_t pin) {
  return analogRead(pin);
}

If this very simple way is good enough, why make things more complicated than they need to be?
 
If this very simple way is good enough, why make things more complicated than they need to be?

Because I tried this:
https://forum.pjrc.com/threads/52569-TCD1304-with-teensy-3-2

He had tried to use the fastest way to read out the ADC

As you have already read in my question:
https://forum.pjrc.com/threads/73676-USB-Timer-AnalogRead-Interrupt
I get strange effects when I use my program described there.
That's why I wanted to see if I can test an even faster method for the ADC.
But maybe USB, interrupt and ADC interfere with each other
 
Back
Top