Dependencies:   mbed

Committer:
okano
Date:
Tue Jul 10 03:45:35 2012 +0000
Revision:
1:066a5725ea59
Parent:
0:c8f89ec4e176
with mbed-lib rev43

Who changed what in which revision?

UserRevisionLine numberNew contents of line
okano 0:c8f89ec4e176 1 // port speed test program
okano 0:c8f89ec4e176 2 // this code is based on ..
okano 0:c8f89ec4e176 3 // http://mbed.org/users/simon/notebook/busout-portout-digitalout-speedup/
okano 0:c8f89ec4e176 4
okano 0:c8f89ec4e176 5 #include "mbed.h"
okano 0:c8f89ec4e176 6
okano 0:c8f89ec4e176 7 BusOut bus(P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31);
okano 0:c8f89ec4e176 8 PortOut port(Port0, 0x00000FF0);
okano 0:c8f89ec4e176 9 DigitalOut out(LED1);
okano 0:c8f89ec4e176 10
okano 0:c8f89ec4e176 11 Timer t;
okano 0:c8f89ec4e176 12
okano 0:c8f89ec4e176 13 int main() {
okano 0:c8f89ec4e176 14 // printf(" ** port speed test **\r\n");
okano 0:c8f89ec4e176 15
okano 0:c8f89ec4e176 16 t.start();
okano 0:c8f89ec4e176 17 for(int i=0; i<1000000; i++) {
okano 0:c8f89ec4e176 18 bus = 0;
okano 0:c8f89ec4e176 19 bus = 0xFF;
okano 0:c8f89ec4e176 20 }
okano 0:c8f89ec4e176 21 printf(" BusOut = %8d kHz\r\n",(int)( 1000.0 / t));
okano 0:c8f89ec4e176 22
okano 0:c8f89ec4e176 23 t.reset();
okano 0:c8f89ec4e176 24 for(int i=0; i<1000000; i++) {
okano 0:c8f89ec4e176 25 port = 0;
okano 0:c8f89ec4e176 26 port = 0xFF000000;
okano 0:c8f89ec4e176 27 }
okano 0:c8f89ec4e176 28 printf(" PortOut = %8d kHz\r\n", (int)(1000.0 / t));
okano 0:c8f89ec4e176 29
okano 0:c8f89ec4e176 30 t.reset();
okano 0:c8f89ec4e176 31 for(int i=0; i<1000000; i++) {
okano 0:c8f89ec4e176 32 out = 0;
okano 0:c8f89ec4e176 33 out = 1;
okano 0:c8f89ec4e176 34 }
okano 0:c8f89ec4e176 35 printf(" DigitalOut = %8d kHz\r\n", (int)(1000.0 / t));
okano 0:c8f89ec4e176 36 }
okano 0:c8f89ec4e176 37