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 ???
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 ...
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: