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.5Die 2MHz-Ausgabe sieht auf dem Oszilloskop so aus:

Check out similar posts by category:
PlatformIO, Teensy
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow