Hi,
I am writing a program with a timer wich will be variable in time. For instance, I am testing the way to change the timer count directly by writing to GPT1_OCR1 with a constant time (100ms), but I have a slow shift and I don't understand why. I have tried with 2400000-1, but it's the same.
with the serial monitor, I get this:
Called at: 400005
Called at: 500005
Called at: 600005
Called at: 700006
Called at: 800006
Called at: 900007
Called at: 1000007
Called at: 1100008
Called at: 1200008
Called at: 1300008
Called at: 1400009
Called at: 1500009
Called at: 1600010
Called at: 1700010
Called at: 1800010
Called at: 1900011
Thanks for your help
Michel
I am writing a program with a timer wich will be variable in time. For instance, I am testing the way to change the timer count directly by writing to GPT1_OCR1 with a constant time (100ms), but I have a slow shift and I don't understand why. I have tried with 2400000-1, but it's the same.
Code:
#include "TeensyTimerTool.h"
using namespace TeensyTimerTool;
PeriodicTimer myTimer(GPT1);
unsigned long compteur;
void printCurrentTime(){
GPT1_OCR1=2400000;
Serial.printf("Called at: %d\n", micros());
digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));
// compteur=compteur+120000;
}
void setup(){
pinMode(LED_BUILTIN,OUTPUT);
compteur=2400000;
myTimer.begin(printCurrentTime, 100ms, false);
GPT1_OCR1=compteur;
myTimer.start();
}
void loop(){
}
Called at: 400005
Called at: 500005
Called at: 600005
Called at: 700006
Called at: 800006
Called at: 900007
Called at: 1000007
Called at: 1100008
Called at: 1200008
Called at: 1300008
Called at: 1400009
Called at: 1500009
Called at: 1600010
Called at: 1700010
Called at: 1800010
Called at: 1900011
Thanks for your help
Michel