‎2021-10-26 11:02 AM
Hello,
I'm using STM32WB55 in conjunction with freeRTOS OS
I found a very good I2C BARE-METAL working example located at:
..\STM32Cube\Repository\STM32Cube_FW_WB_V1.12.1\Projects\P-NUCLEO-WB55.Nucleo\Examples\I2C\I2C_TwoBoards_AdvComIT
I'm looking for a similar I2C Example, however based on and using
freeRTOS implementation
Thanks In Advance,
Micha
Solved! Go to Solution.
‎2021-10-27 09:44 PM
Hi KnafB,
Thanks you very much for your GREAT advise :smiling_face_with_smiling_eyes: !!!
The original I2C example is based on HAL functions: HAL_I2C_Master_Transmit_IT() and HAL_I2C_Master_Receive_IT
I added freeRTOS with CMSIS_V2 (from CubeMX) + one I2C task, copy the I2C functionality from Main loop to the I2C task, DONE - ALL work like a charm !!!
Many Thanks
Best Regards,
Micha
‎2021-10-27 07:20 AM
The FreeRTOS middleware is just the RTOS kernel, i.e. scheduler + synchronisation objects, no peripherals API. So you just use HAL as in the above example from a FreeRTOS task. HAL is not aware of RTOS, so the timing might be different (when the task is not running).
hth
KnarfB
‎2021-10-27 12:03 PM
Hi KnarfB,
Thanks for your reply
Will create an I2C Task then try to perform HAL_I2C_*** procedure
Best Regards,
Micha
‎2021-10-27 12:15 PM
Right. Keep in mind that the blocking HAL functions like HAL_I2C_Master_Transmit (with timeout) are not RTOS friendly because they don't "tell" the RTOS that they are busy waiting (=MCU using) for a condition. If you need more efficiency, you might want to use the non-blocking _IT or _DMA HAL functions and implement the interrupt&completion callbacks such that they e.g. return data in a FreeRTOS queue. This efficiency comes with more code complexity, so do it only when really needed.
hth
KnarfB
‎2021-10-27 09:44 PM
Hi KnafB,
Thanks you very much for your GREAT advise :smiling_face_with_smiling_eyes: !!!
The original I2C example is based on HAL functions: HAL_I2C_Master_Transmit_IT() and HAL_I2C_Master_Receive_IT
I added freeRTOS with CMSIS_V2 (from CubeMX) + one I2C task, copy the I2C functionality from Main loop to the I2C task, DONE - ALL work like a charm !!!
Many Thanks
Best Regards,
Micha
‎2022-09-30 03:33 AM
But still it's not clear what you did. If possible please post that part you edited.
‎2022-10-01 08:54 PM