Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
4 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
4 months ago.
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.
- 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