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.
8 years, 7 months ago.
Serial Interups and mbed-rtos
Hi,
I have a problem that if i include the rtos library on the 1768 as soon as my serial rx interrupt is triggered it seems to stall. see this repo for an example https://developer.mbed.org/users/chrissnow/code/serialinterrupttest/
what's really odd is that removing the rtos library doesn't fix it, only creating a new program and never adding the rtos seems to work.
1 Answer
8 years, 7 months ago.
Compile -> compile all should also fix it.
You need to use RawSerial, regular Serial can't be read during interrupts, and you need to read to use the RX interrupt. Just replace 'Serial' with 'RawSerial'.
Thanks for the info. Is this the best approach when using the rtos with serial? Happy to do something different if there is.
posted by 10 Jun 2016Yes that is the best approach.
Bit of summary: Regular Serial uses C stdio library as in-between layer for also things like printf. C stdio library wants to take exclusive control of the Serial in RTOS. However this is done with a mutex, and they are not allowed in interrupt context, locking up your device.
RawSerial does not use the C stdio layer. Popular ones like printf are implemented 'manually', but you don't have all the C stdio functions when using RawSerial. However your basic Serial is there, and functions properly also in interrupts.
posted by 10 Jun 2016