4 years, 5 months ago.

BusOut fail in ticker attached member fucntion.

Hello everyone, When try to busout.write() in member function that attached a ticker, mcu fails. I find a solution but cant understand what happening. My solution is removing lock() and unlock() funtion at BusOut::write() member function in BusOut.cpp. I think this solution not good. Can someone explain what is going on and give properly solution.

My target: stm32f072rb mbed-os 5.14

1 Answer

4 years, 5 months ago.

Hi there,

the mcu fails, because of a mutex what is contained in the method BusOut::write() and when your function with that method is called by the ticker, it is in the interrupt context and the mutex can not by used in interrupt context = fail.

Possible solutions

  • your solution with removing Lock and Unlock methods or also can be replaced with empty scopes
  • If you not need RTOS functionality you can use MbedOS5 with bare metal profile, it is MbedOS5 without RTOS = no mutexes.
  • generate a bool flag with a ticker and inside a separete thread in a loop you can check the flag and process what you need.
  • maybe something more

Same problems can occur with others Apis/drivers like CAN, Serial and so on.

Best regards, Jan

Accepted Answer

Thanks for answering Jan. How can set bare metal profile

posted by abdurrahman uslu 25 Oct 2019

You are welcome.

However, I am not sure about the following sentence is a question or not because me En is little bit limited. So for sure... How you can Enabling Mbed OS bare metal you can found on the end of this page.

posted by Jan Kamidra 25 Oct 2019