teensy 3.1 bug and vref

manitou

Senior Member+
I posted this on the 3.1/r17 announcement, but I'll repost here... and in the intervening time I think I have found the problem.

The following little sketch worked on teensy 3.0 and reported the voltage level of Vcc using the internal reference voltage, so you can check your battery level. Similar ADC trick works on UNO and maple, but this no longer worked on teensy 3.1. On 3.1 the sketch reported varying values from 6000 to 8000 ???

Code:
void setup() {
  analogReference(DEFAULT);
  analogReadResolution(12);
  analogReadAveraging(32);
}

void loop() {
  int mv;
  mv = 1200 * 4096 /analogRead(39);
  Serial.println(mv);
  delay(2000);
}

Looking at analog.c and the 3.0 and 3.1 ARM reference manual, the VREF channel for ADC0 is 22, but for ADC1 (teensy 3.1) the VREF channel is 18. (the temperature channel sensor channel is 26 on both ADC0 and ADC1 so my chiptemp sketch worked on both 3.0 and 3.1). I hacked analog.c and changed channel2sc1a[] for __MK20DX256__, changing 22 to 128+18 and that seemed to fix the 3.1 problem.

the sketch now reports 3343 mv

Now to figure out why DMA memory-to-memory is twice as slow on 3.1 vs 3.0 ...
 
Last edited:
Yeah, on Teensy 3.1 some of the analog inputs connect differently.

I also found at least one bug in the chip, where A13 only connects to ADC1. The manual says it also connects to ADC0, but clearly it does not.

Now to figure out why DMA memory-to-memory is twice as slow on 3.1 vs 3.0 ...

I have a service request in to Freescale regarding this issue.
 
Bump. Paul I still don't see a patch in analog.c in your github tree for this analog pin fix? It may be low priority, but I was curious if you were unable to vet it, or ?

I hacked analog.c and changed channel2sc1a[] for __MK20DX256__, changing 22 to 128+18 and that seemed to fix the 3.1 problem.
 
Back
Top