Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 //  port speed test program
00002 //  this code is based on ..
00003 //    http://mbed.org/users/simon/notebook/busout-portout-digitalout-speedup/
00004 
00005 #include "mbed.h"
00006 
00007 BusOut bus(P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31);
00008 PortOut port(Port0, 0x00000FF0);
00009 DigitalOut out(LED1);
00010 
00011 Timer t;
00012 
00013 int main() {
00014 //    printf("    ** port speed test **\r\n");
00015 
00016     t.start();
00017     for(int i=0; i<1000000; i++) {
00018         bus = 0;
00019         bus = 0xFF;
00020     }
00021     printf("    BusOut  = %8d kHz\r\n",(int)( 1000.0 / t));
00022 
00023     t.reset();
00024     for(int i=0; i<1000000; i++) {
00025         port = 0;
00026         port = 0xFF000000;
00027     }
00028     printf("    PortOut = %8d kHz\r\n", (int)(1000.0 / t));
00029     
00030     t.reset();
00031     for(int i=0; i<1000000; i++) {
00032         out = 0;
00033         out = 1;
00034     }
00035     printf("    DigitalOut = %8d kHz\r\n", (int)(1000.0 / t));
00036 }
00037