cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with sensor and freertos

Dcapu.2440
Associate II

Hi i have a problem. When i use a sensor with freertos and i put in the same task the function to read the value from the sensor and the osdelay() my task do one misuration and after do nothing. I print the value with the HAL_UART_Transmit.

11 REPLIES 11

After reading this: https://simonmartin.ch/resources/stm32/dl/STM32%20Tutorial%2003%20-%20UART%20Communication%20using%20HAL%20(and%20FreeRTOS).pdf

I absolutely agree 🙂 As i said: I never used UART before on MCU´s :( Just SPI and I2C, where the send- and receive-functions have been in the libraries for the used hardware to communicate with. In these cases i never got any trouble with using FreeRTOS... Still to learn a lot, when it comes to C/C++ 🙂 Especially in RTOS´s, i know much less, than in internal structures of the hardware 🙂

My next Try would be to do the sampling of the sensor in a dedicated task (maybe the sampling triggered by a timer?), when it´s ready, send the data to the uart task and try to transmit the preprepared data then via uart ... What happens, if you fill the data array at initialization with some data and don´t alter it anymore ? (just comment out the sensor reading). If it works correct, the problem really lies in BSP_TSENSOR_ReadTemp.