Hi, I have a code written below. It has to send some data on my pc each 10 ms. Also, I want to send a single number back via the same uart. It works fine until I send anything, then it stops completely.
Hi @lav522
What is the board you are using?
Could you confirm that PA_2 pin is in fact the SERIAL_TX pin, and that it is correctly configured?
Regards,
Mbed support
Ron
Yes, you were right about that, now, when i’m adding \n it doesn’t stop. But I have another problem: it doesn’t receive my messages each time, so I have to press “send” button 10-20 times until it gets it.
You don’t want to use scanf in a character interrupt. It’s better to use an interrupt handler that only takes a character and then process the buffer when characters are received. PC.readable only tells you that at least 1 character is available. scanf wants a full line with CRLF in it.
Grab characters via interrupt and then just process the buffer on a regular interval and you should be ok.