alex burton
/
BinaryCounter
Simple Binary Counter on PortA, will toggle bits at it counts.
main.cpp@1:cb458d5f9927, 2014-12-19 (annotated)
- Committer:
- afbc0m
- Date:
- Fri Dec 19 22:24:03 2014 +0000
- Revision:
- 1:cb458d5f9927
- Parent:
- 0:bd7ff9bb0542
Rev2;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
afbc0m | 0:bd7ff9bb0542 | 1 | #include "mbed.h" |
afbc0m | 0:bd7ff9bb0542 | 2 | |
afbc0m | 0:bd7ff9bb0542 | 3 | PortOut LEDS(PortA, 0xFFFF); |
afbc0m | 0:bd7ff9bb0542 | 4 | |
afbc0m | 0:bd7ff9bb0542 | 5 | #define loopDelay 0 //Loop Execution time |
afbc0m | 0:bd7ff9bb0542 | 6 | #define tickPerFrame 1 |
afbc0m | 0:bd7ff9bb0542 | 7 | #define frameTime 33333 |
afbc0m | 0:bd7ff9bb0542 | 8 | #define tick frameTime/tickPerFrame |
afbc0m | 0:bd7ff9bb0542 | 9 | #define tickrate (tick-loopDelay) //uS |
afbc0m | 0:bd7ff9bb0542 | 10 | |
afbc0m | 0:bd7ff9bb0542 | 11 | unsigned short Count = 0; |
afbc0m | 0:bd7ff9bb0542 | 12 | |
afbc0m | 0:bd7ff9bb0542 | 13 | |
afbc0m | 0:bd7ff9bb0542 | 14 | int main() { |
afbc0m | 0:bd7ff9bb0542 | 15 | while(1) { |
afbc0m | 0:bd7ff9bb0542 | 16 | Count++; |
afbc0m | 0:bd7ff9bb0542 | 17 | LEDS = Count; |
afbc0m | 0:bd7ff9bb0542 | 18 | wait_us(tickrate); |
afbc0m | 0:bd7ff9bb0542 | 19 | } |
afbc0m | 0:bd7ff9bb0542 | 20 | } |
afbc0m | 0:bd7ff9bb0542 | 21 |