banans
Member
Hello,
I'm trying to implement the ChRt library on a Teensy 4.0 board, and I'm starting with a simple blinking LED function. I'm just trying to follow a basic example, but it's not working and I'm getting unexpected behavior.
First off, here's my code:
Not only does the LED on the board not blink, but I don't get any Serial output either. Commenting out the chBegin and while loop below it yields Serial output.
Note: I'm using PlatformioIDE (Core 5.0.1 Home 3.3.1) on macOS Catalina 10.15.7
Anything helps, I'm very stuck!
I'm trying to implement the ChRt library on a Teensy 4.0 board, and I'm starting with a simple blinking LED function. I'm just trying to follow a basic example, but it's not working and I'm getting unexpected behavior.
First off, here's my code:
Code:
#include <Arduino.h>
#include <ChRt.h>
// working area
static THD_WORKING_AREA(waThreadHEART, 64);
// actual function
static THD_FUNCTION(ThreadHEART, arg)
{
(void)arg;
//basic heartbeat thread to tell us whether weve crashed
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
while (1)
{
digitalWrite(LED_BUILTIN, HIGH);
chThdSleepMilliseconds(83);
digitalWrite(LED_BUILTIN, LOW);
chThdSleepMilliseconds(166);
digitalWrite(LED_BUILTIN, HIGH);
chThdSleepMilliseconds(125);
digitalWrite(LED_BUILTIN, LOW);
// Serial.print(".");
chThdSleepMilliseconds(626);
}
}
void chStartup()
{
chThdCreateStatic(waThreadHEART, sizeof(waThreadHEART),
NORMALPRIO + 1, ThreadHEART, NULL);
}
void setup()
{
Serial.begin(9600);
while (!Serial)
{
delay(1);
}
Serial.println("Serial was started!");
chBegin(chStartup);
while(1) {}
}
void loop()
{
}
Not only does the LED on the board not blink, but I don't get any Serial output either. Commenting out the chBegin and while loop below it yields Serial output.
Note: I'm using PlatformioIDE (Core 5.0.1 Home 3.3.1) on macOS Catalina 10.15.7
Anything helps, I'm very stuck!