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@2:7372f9e25216, 2012-07-10 (annotated)
- Committer:
- okano
- Date:
- Tue Jul 10 02:10:08 2012 +0000
- Revision:
- 2:7372f9e25216
- Parent:
- 0:9ed7b15638cd
port speed test in beta env. mbed-rev40 (latest in beta env)
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| okano | 0:9ed7b15638cd | 1 | // port speed test program | 
| okano | 0:9ed7b15638cd | 2 | // this code is based on .. | 
| okano | 0:9ed7b15638cd | 3 | // http://mbed.org/users/simon/notebook/busout-portout-digitalout-speedup/ | 
| okano | 0:9ed7b15638cd | 4 | |
| okano | 0:9ed7b15638cd | 5 | #include "mbed.h" | 
| okano | 0:9ed7b15638cd | 6 | |
| okano | 0:9ed7b15638cd | 7 | BusOut bus(P1_24, P1_25, P1_26, P1_27, P1_28, P1_29, P1_30, P1_31); | 
| okano | 0:9ed7b15638cd | 8 | PortOut port(Port0, 0x00000FF0); | 
| okano | 0:9ed7b15638cd | 9 | DigitalOut out(LED1); | 
| okano | 0:9ed7b15638cd | 10 | |
| okano | 0:9ed7b15638cd | 11 | Timer t; | 
| okano | 0:9ed7b15638cd | 12 | |
| okano | 0:9ed7b15638cd | 13 | int main() { | 
| okano | 0:9ed7b15638cd | 14 | // printf(" ** port speed test **\r\n"); | 
| okano | 0:9ed7b15638cd | 15 | |
| okano | 0:9ed7b15638cd | 16 | t.start(); | 
| okano | 0:9ed7b15638cd | 17 | for(int i=0; i<1000000; i++) { | 
| okano | 0:9ed7b15638cd | 18 | bus = 0; | 
| okano | 0:9ed7b15638cd | 19 | bus = 0xFF; | 
| okano | 0:9ed7b15638cd | 20 | } | 
| okano | 0:9ed7b15638cd | 21 | printf(" BusOut = %8d kHz\r\n",(int)( 1000.0 / t)); | 
| okano | 0:9ed7b15638cd | 22 | |
| okano | 0:9ed7b15638cd | 23 | t.reset(); | 
| okano | 0:9ed7b15638cd | 24 | for(int i=0; i<1000000; i++) { | 
| okano | 0:9ed7b15638cd | 25 | port = 0; | 
| okano | 0:9ed7b15638cd | 26 | port = 0xFF000000; | 
| okano | 0:9ed7b15638cd | 27 | } | 
| okano | 0:9ed7b15638cd | 28 | printf(" PortOut = %8d kHz\r\n", (int)(1000.0 / t)); | 
| okano | 0:9ed7b15638cd | 29 | |
| okano | 0:9ed7b15638cd | 30 | t.reset(); | 
| okano | 0:9ed7b15638cd | 31 | for(int i=0; i<1000000; i++) { | 
| okano | 0:9ed7b15638cd | 32 | out = 0; | 
| okano | 0:9ed7b15638cd | 33 | out = 1; | 
| okano | 0:9ed7b15638cd | 34 | } | 
| okano | 0:9ed7b15638cd | 35 | printf(" DigitalOut = %8d kHz\r\n", (int)(1000.0 / t)); | 
| okano | 0:9ed7b15638cd | 36 | } | 
| okano | 0:9ed7b15638cd | 37 |