0

I am using freeRTOS on STM32F4x. I am reading MPU6050 MEMS sensor on I2C2 peripheral. When I am just in bare metal mode, the HAL_I2C_Mem_Read function works just fine and returns me the ID of the sensor. However, when i am running with freeRTOS this function is always returning me HAL_TIMEOUT.

As a side note, the interrupt service routine for calling freeRTOS context switching is different from HAL time base. in this case my Timer 7 is used for calling freeRTOS context switching related stuff, while systick handler is kept for HAL time base functionality.

Does someone have any idea why would this simply go wrong?

Bests, Junaid

  • Try and disable the interrupts before you make the read to see if this is the problem. – MathiasE May 19 '22 at 08:47
  • Why would this be a problem? Personally, I have resolved it by making my own implementation, but I would still like to understand this problem. Irrespective of how long the timeout I provide, it still always times out. For some reason, some flag is not getting set under freeRTOS. Anyhow, STM HAL is still not up to the mark in many scenarios. – Sheikh Muhammad Junaid Aslam May 20 '22 at 09:03
  • Interrupts can on most architectures can be given a priority, so that one interrupt have higher priority than another. If this is the case, and you are waiting for another interrupt while already inside an interrupt it can be a problem with deadlock. – MathiasE May 20 '22 at 13:48

0 Answers0