Teensy 4.0 wrong register in cores analog.c ?

Status
Not open for further replies.

ossi

Well-known member
In the Teensy 4.0 cores file analog.c is the following line:
ADC1_CFG = mode | ADC_HC_AIEN | ADC_CFG_ADHSC;
As far as I understand the register ADC1_CFG gets initialized here. But the bit ADC_HC_AIEN does not belong to register ADC1_CFG but to "Control register for hardware triggers (ADCx_HC0)" as far as I understand the datasheet. Or do I understand it wrongly?
 
For what it is worth, I agree. @PaulStoffregen, there is definitely something odd here.

In cores/teensy4/analog.c:analog_init(), the ADC1_CFG = mode | ADC_HC_AIEN | ADC_CFG_ADHSC; line is equivalent to ADC1_CFG = mode | ADC_CFG_ADLPC | ADC_CFG_ADHSC; , always forcing low-power mode. I suppose it should be ADC1_CFG = mode | ADC_CFG_OVWREN | ADC_CFG_ADHSC; instead, so that the next converted sample overwrites the existing value in the data result register?
 
Yes looks wrong! It has been this way since the file was original added at the start of T4...

@Paul - not sure of the right Fix. That is was the code originally setup by BIT value and was translated to a symbolic name for it...
In which case probably should be: ADC1_CFG = mode | ADC_CFG_ADLPC | ADC_CFG_ADHSC;

That is, is it intentional to set the ADC in low power conversion mode (ADLPC)

Note: likewise for ADC2 a couple of lines down.
 
If low-power mode is enabled it should be checked whether this is compatible with high-speed mode.
 
I have checked the option bits for the ADC. The Teensy 4.0 seems to enable "Low Power Mode" if nothing special is done.
 
Status
Not open for further replies.
Back
Top