Aldo Bucio
Member
I need to use an RTOS in my Teensy 4.0 that has some scheduling algorithm such as Free-RTOS,
one of the most famous that can be implemented in the arduino IDE.
I have been using these libraries without any success:
https://github.com/discord-intech/FreeRTOS-Teensy4
https://github.com/greiman/FreeRTOS-Arduino
https://github.com/tsandmann/freertos-teensy
I read in some threads like this:
https://forum.pjrc.com/threads/41504-Teensy-3-x-multithreading-library-first-release
I can use this library to do parallel processes, however I see that since it does not have a scheduling algorithm,
I cannot synchronize the tasks properly as a mutex or a semaphore would do.
As can be seen in the code, there are 2 trains of square pulses, one has twice the frequency of the other, and when reviewing it through an oscilloscope, I observe that one of the pulses with form passes over time and moves with respect to the other , that is, it gets out of sync after a while.
I need the pulse trains to be synchronized or in phase always and working in parallel with other tasks.
In my opinion, if I am able to use a scheduler like the one offered by Free-RTOS, I will be able to solve my problem.
How can I implement Free-RTOS or other RTOS on Teensy 4.0?
Thank you very much in advance for your attention.
one of the most famous that can be implemented in the arduino IDE.
I have been using these libraries without any success:
https://github.com/discord-intech/FreeRTOS-Teensy4
https://github.com/greiman/FreeRTOS-Arduino
https://github.com/tsandmann/freertos-teensy
I read in some threads like this:
https://forum.pjrc.com/threads/41504-Teensy-3-x-multithreading-library-first-release
I can use this library to do parallel processes, however I see that since it does not have a scheduling algorithm,
I cannot synchronize the tasks properly as a mutex or a semaphore would do.
Code:
#include <Arduino.h>
#include "TeensyThreads.h"
const int LED_RED = 15;
const int LED_GREEN = 19;
const int PUSH = 23;
int count = 0;
void blinkRed(){
while (1) {
digitalWrite(LED_RED, HIGH);
threads.delay(250);
digitalWrite(LED_RED, LOW);
threads.delay(250);
threads.yield();
}
}
void blinkGreen() {
while (1) {
digitalWrite(LED_GREEN, HIGH);
threads.delay(500);
digitalWrite(LED_GREEN, LOW);
threads.delay(500);
threads.yield();
}
}
void push() {
while (1) {
if(digitalRead(PUSH) == 0){
while(digitalRead(PUSH) == 0){
count++;
Serial.print("TOCO ");
Serial.println(count);
threads.delay(250); // efecto rebote
}
}
threads.yield();
}
}
void setup() {
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_RED, OUTPUT);
pinMode(PUSH, INPUT_PULLUP);
threads.addThread(blinkRed);
threads.addThread(blinkGreen);
threads.addThread(push);
}
void loop() {
// nada
}
As can be seen in the code, there are 2 trains of square pulses, one has twice the frequency of the other, and when reviewing it through an oscilloscope, I observe that one of the pulses with form passes over time and moves with respect to the other , that is, it gets out of sync after a while.
I need the pulse trains to be synchronized or in phase always and working in parallel with other tasks.
In my opinion, if I am able to use a scheduler like the one offered by Free-RTOS, I will be able to solve my problem.
How can I implement Free-RTOS or other RTOS on Teensy 4.0?
Thank you very much in advance for your attention.