2 years, 4 months ago.

CAN attach function doesn't work properly on STM32F103C8T6

Hi, I'm using an STM32F103C8T6 Bluepill and working with the CAN bus. I can run this (https://os.mbed.com/users/hudakz/code/CAN_Hello/ ) example code just fine, only changing the outdated mbed library for the recent mbed-os version and eliminating the "stm32f103c8t6.h" library that was essential in the past. The code runs ok when i'm polling the bus, but when I attach the interrupt, it just stops working (I can't read the message even if the callback is empty and the read() function is in the loop).

2 Answers

2 years, 4 months ago.

Hello Diego,

CAN (SPI, I2C ...) read method cannot be called in an Interrup Service Routine (ISR) because read locks the Mutex (that is "Mutex method is called"), which is not allowed in context of ISR anymore. Read here for more info.

1 year, 8 months ago.

So this is confusing because the CAN documentation here <https://github.com/ARMmbed/mbed-os/issues/5267> says the way to clear the interrupt is to call CAN.read?