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; 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:
Error: ControlTask - Inconsistency detected between expected and actual sensor value
Error: ControlTask - Inconsistency detected between expected and actual sensor value
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
Jump to solution
3 Replies
UC GEE
UC GEE2w ago
Do you know how to use queue ? Instead of using global variable. @Marvee Amasi
Marvee Amasi
Marvee Amasi2w ago
@UC GEE okay I do in a way , but it's just what I am working with
Solution
UC GEE
UC GEE2w ago
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
Want results from more Discord servers?
Add your server
More Posts
trying to code a stm32 board and receiving this error how to fix it - Target no device foundi am trying to code a stm32 board and receiving this error how to fix it - Target no device found EIs it safe to cast the osThreadId pointer to a 32-bit integer for a unique thread ID across platformHey friends, Porting a product to a CMSIS RTOS. We need a 32-bit integer representing the thread IDWhy is power consumption higher in standby mode than stop mode on an STM32F411CEU6?Hey, anyone who might have a clue what's going on? Currently doing some energy-measurements on an STohk then , i will ask my dad to help weohk then , i will ask my dad to help we with few internshipsDIY ESP32-Based Smartwatch with LiDAR and Wi-Fi ScanningThis project features the ESP32 microcontroller, integrating advanced environmental monitoring and ITrying to establish SPI communication between two ArduinosI'm trying to establish SPI communication between two Arduinos. When I directly wire pins 10, 11, 12How can we strike a balance between security and performance in IoT devices?How can we strike a balance between security and performance in IoT devices, especially low-power onManaging Priorities in a CAN Bus Network with Arduino Uno and MCP2515 Moduleshello everyone, i have a project of realizing CAN bus, to achieve it i use two Arduinos uno and two How do I set and manage interrupt priorities in FreeRTOS?@Middleware & OS How do I set and manage interrupt priorities in FreeRTOS? My higher priority interIf I write a Python program with a GUI, can I launch it from the Linux CLI and still get the GUI?I'm expecting the answer to be no, but I want to confirm. If I write a Python program with a GUI, ca