Teensy 4.1 PlatformIO 2MHz Timer-Interrupt GPIO-Ausgabe

English Deutsch

Das folgende PlatformIO-Beispiel verwendet TeensyTimerTool auf dem Teensy 4.1, um einen einfachen GPIO-Toggling-Interrupt mit 4 MHz Interrupt-Frequenz auszuführen (d.h. der Interrupt wird 4 Millionen Mal pro Sekunde ausgeführt), was eine 2 MHz GPIO-Ausgabe ergibt:

teensy_periodic_timer_example.cpp
#include <Arduino.h>
#include <TeensyTimerTool.h>
using namespace TeensyTimerTool;

PeriodicTimer t1(GPT2);

void callback() // LED togglen
{
    digitalWriteFast(33, !digitalReadFast(33));
}

void setup()
{
    t1.begin(callback, 250ns);

    pinMode(33, OUTPUT);
}

void loop()
{
}

platformio.ini:

platformio.ini
[env:teensy41]
platform = teensy
board = teensy41
framework = arduino
lib_deps = luni64/TeensyTimerTool @ ^0.3.5

Die 2MHz-Ausgabe sieht auf dem Oszilloskop so aus:

Oszilloskop-Spur der Teensy 4.1 2 MHz GPIO-Ausgabe aus Timer-Interrupt


Check out similar posts by category: PlatformIO, Teensy