joseactus
(José Carlos Montoya Coboj)
September 2, 2019, 4:44pm
1
I’ve been trying to transmit and receive information through the serial port in my NUCLEO-F072RB using mbed-os 5.12 with some particular problems.
I have tested serial.getc() in my main loop and it worked fine, but now I want to use a callback whenever I get new information to avoid the blocking call and it does not seem to work. When I send something through the serial port led1 starts blinking (4 times at normal pace, then 3 fast blinks) and it appears that the code gets stuck in the callback.
My code looks like this:
#include "mbed.h"
Serial pc(PC_4, PC_5, 9600);
volatile char c = 'n';
bool charReceived;
DigitalOut led1(LED1);
void onCharReceived(){
c = pc.getc();
charReceived = true;
}
int main() {
DigitalOut led1(LED1);
pc.printf("Start \n");
pc.attach(&onCharReceived, Serial::RxIrq);
while(1){
if(charReceived == true){
led1 = true;
wait(1);
led1 = false;
pc.printf("%c \n", c);
charReceived = false;
}
}
}
Any suggestions of what I may be missing?
Thanks in advance.
sayhuthut
(Desmond Chen)
September 3, 2019, 5:04am
2
Hi José ,
It’s an issue long time ago…, please refer here
opened 01:53AM - 24 Oct 18 UTC
closed 01:34PM - 31 Oct 18 UTC
type: bug
### Description
I wrote a following program and works fine on OS5.9.7 but erro… r is happened on OS5.10. 0, 5.10.1 and 5.10.2.
Target Board: Nucleo-F446RE
https://os.mbed.com/users/kenjiArai/code/Mutex_lock_failed_on_os_5_10/
The error message is below.
```
++ MbedOS Error Info ++
Error Status: 0x80020115 Code: 277 Module: 2
Error Message: Mutex lock failed
Location: 0x8005B01
Error Value: 0xFFFFFFFA
Current Thread: Id: 0x200024D8 Entry: 0x8007045 StackSize: 0x1000 StackMem: 0x200014D8 SP: 0x2001FF50
For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80020115
-- MbedOS Error Info --
```
Looks like OS internal RTX Kernel bug.
Please give me an advice how to overcome this issue.
### Issue request type
[ ] Question
[ ] Enhancement
[x] Bug
We recommend to use RawSerial when you want to use RxIrq callback.
And I think you should use volatile also on charReceived.
Regards,
Desmond
joseactus
(José Carlos Montoya Coboj)
September 3, 2019, 4:28pm
3
Thanks! Using raw serial worked out.