Utility of TIF in TFLG0 in a PIT timer

Status
Not open for further replies.

michastro

Member
Hello,
I have write a small program to test the use of TIF in TFLG0 of a PIT timer on a Teensy 4.0. I can't see the utility of this flag, It's a value of 0 between interrupt, 1 at the beginning of the interrupt, and automatically cleared after. It can be replaced by a volatile flag inside the interrupt. In my program, every 4s, "flag=1" is send.
Code:
#include "TeensyTimerTool.h"
using namespace TeensyTimerTool;


PeriodicTimer myTimer(PIT);
volatile int flag;

void printCurrentTime() {
  digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN));
}

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN,HIGH);
  myTimer.begin(printCurrentTime, 4000ms, false);
  myTimer.start();
}

void loop() {
  do{
    flag=PIT_TFLG0;  
  }
  while(flag==0);
  Serial.printf("flag =%d\r\n",flag);
}
Thanks
Michel
 
Status
Not open for further replies.
Back
Top