Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 // Test app to cause program to suddently terminate when using serial interrupt... 00004 // Line 24 seems to be the important bit, but I don't really understand why? 00005 // Is it perhaps the putc is peroperly clearing the interrupt flag instead of the getc? 00006 00007 00008 // usb serial device defaults to 9600 baud, 8N1 on /dev/ttyACM0 (in Linux!) 00009 Serial pc(USBTX, USBRX); // tx, rx 00010 00011 // debugging LEDs 00012 DigitalOut interrupt(LED1); 00013 DigitalOut tx(LED4); 00014 00015 // one byte receive buffer 00016 char rx_byte; 00017 00018 void handle() 00019 { 00020 interrupt = 1; 00021 //if(pc.readable()) // <--- this line doesn't matter either way... 00022 { 00023 rx_byte = pc.getc(); 00024 //pc.putc(rx_byte); // <--- WITHOUT THIS LINE, THE APPLICATION WILL HANG IF IT RECEIVES WHILE SENDING! 00025 } 00026 interrupt = 0; 00027 return; 00028 } 00029 00030 int main() 00031 { 00032 interrupt = 0; 00033 tx = 0; 00034 pc.attach(handle); 00035 00036 while(1) 00037 { 00038 // send a long string of bytes 00039 tx = 1; 00040 for(int i=0;i<20;i++) 00041 { 00042 pc.printf("If I receive while transmitting this I will crash...\r\n"); 00043 } 00044 tx = 0; 00045 00046 wait(1.0); 00047 } 00048 }
Generated on Wed Jul 20 2022 00:46:33 by
1.7.2