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.
9 years, 10 months ago.
Timer delays and interrupts interfere with UART output
I'm having trouble getting my code to work. I'm using the RawSerial library but using timer delays or interrupts seem to mess it up. The program shown below will print nothing to the UART, at least as far as my PC can. If I comment out both the line that attaches the interrupt to the handler AND the line with the delay, then it will print 'a's to the console as expected. But with either of those statements in there, I get nothing.
Any idea what could be happening here?
include the mbed library with this snippet
#include "mbed.h" DigitalOut myled(LED_GREEN); RawSerial pc(USBTX, USBRX); void uart_handler(void) { pc.putc(pc.getc()); } int main() { pc.baud(115200); pc.attach(&uart_handler); //UART will print nothing unless this is commented out while (true) { wait_ms(500); //UART will print nothing unless this is commented out pc.putc('a'); pc.putc('\n'); } }
Can you make sure your mbed library is up to date? (Right mouse button on it, click update). And if you use regular Serial, does it work?
posted by Erik - 11 Feb 2015