See when a UART looses framing based on baudrate shmoo

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // See when the rx UART looses framing based on baudrate shmoo, sford
00002 // connect p13 to p10
00003 
00004 #include "mbed.h"
00005 
00006 Serial device(p13, NC);
00007 Serial m(NC, p10);
00008 
00009 int main() {
00010     m.baud(4800);
00011     m.format(8, Serial::Even, 1);
00012     device.format(8, Serial::Even, 1);
00013 
00014     for(int baud_rate=4800; baud_rate>=4000; baud_rate -= 25) {
00015         device.baud(baud_rate);
00016         device.printf("Hello world! How are you today! Hello world! How are you today!\n");
00017 
00018         wait(0.05);
00019 
00020         int frame_error = (LPC_UART3->LSR >> 3) & 1;
00021         m.getc();  
00022 
00023         printf("baud_rate: %d, frame_error: %d\n", baud_rate, frame_error);
00024     }
00025 }