Hello,
I’m using FreeRTOS v10.4.5 on an Arduino Teensy 4.0 (TeensDuino 1.57, IDE 2), with the PWMServo library (find it on github) .
Everytime I call Servo.write
, the task freezes and the led is blinking 4 times every 4 s.
I guess it could be a kernel status…
Where can I find it?
What do you think about this problem?
My code:
/****************************************************************
*
* ** This example is based on InvenSense's _confidential_ Application Note "Programming Sequence for DMP Hardware Functions".
* ** We are grateful to InvenSense for sharing this with us.
*
* ** Important note: by default the DMP functionality is disabled in the library
* ** as the DMP firmware takes up 14301 Bytes of program memory.
* ** To use the DMP, you will need to:
* ** Edit ICM_20948_C.h
* ** Uncomment line 29: #define ICM_20948_USE_DMP
* ** Save changes
* ** If you are using Windows, you can find ICM_20948_C.h in:
* ** Documents\Arduino\libraries\SparkFun_ICM-20948_ArduinoLibrary\src\util
*
* Please see License.md for the license information.
*
* Distributed as-is; no warranty is given.
***************************************************************/
/***************************************************************
* V1.1 :
*/
#include <Arduino.h>
#include "arduino_freertos.h"
#include <PWMServo.h>
#define DEBUG
#define Serial Serial
#define AD0_VAL 1 // The value of the last bit of the I2C address. \
// On the SparkFun 9DoF IMU breakout the default is 1, and when \
// the ADR jumper is closed the value becomes 0
// PINOUT
#define ICM_SDA 18
#define ICM_SCL 19
#define OLED_SDA 17
#define OLED_SCL 16
#define SERVO_PWM 2
#define CYCLE_TIME 3
//#define CORRECTION_ACTIVE 4
PWMServo myServo;
int8_t blinkState, cycle;
// Logging timer interrupt
static void task_ICM( void *) {
for (;;) {
cycle = !cycle;
digitalWriteFast(CYCLE_TIME, cycle);
myServo.write(90);
::vTaskDelay(10);
} // For ever
}
void setup()
{
pinMode(CYCLE_TIME,arduino::OUTPUT); //cycle time measure
pinMode(SERVO_PWM,arduino::OUTPUT); //Servo PWM
Serial.begin(115200); // Start the serial console
while (Serial.available()) // Make sure the serial RX buffer is empty
Serial.read();
delay(100);
// Initialize Servo
myServo.attach(SERVO_PWM);
myServo.write(90);
Serial.println();
Serial.println(PSTR("Configuration complete!"));
arduino::Serial.println(PSTR("\r\nrunning FreeRTOS kernel " tskKERNEL_VERSION_NUMBER "."));
::xTaskCreate(task_ICM, "task_ICM", 2048, nullptr, 3, nullptr);
::vTaskStartScheduler();
}
void loop()
{
}