How can I debug this communication issue to ensure ControlTask always reads the latest data?
@Middleware & OS I'm working on a robotic arm controlled by FreeRTOS with two tasks;
Error Message:
How can I debug this communication issue to ensure ControlTask always reads the latest data?
SensorTask which continuously reads joint angles and stores them in a shared variable (a global array), and ControlTask which retrieves sensor data and calculates motor commands every 10ms.ControlTask sometimes reads outdated data, causing jittery movements. I've verified SensorTask updates the variable correctly.Error Message:
How can I debug this communication issue to ensure ControlTask always reads the latest data?
Solution
If you must use a global variable try a semaphore to protect the shared variable during access. The sensor task acquires the semaphore before updating the variable , and the control task acquires it before reading the variable all these are so you can make only one task access the variable at a time. @Marvee Amasi