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@0:9a1865214ee0, 2015-01-07 (annotated)
- Committer:
- edumana
- Date:
- Wed Jan 07 16:41:41 2015 +0000
- Revision:
- 0:9a1865214ee0
- Child:
- 1:158078765a61
Program that uses registers to blink the green and red LEDs on the FRM K22F board.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| edumana | 0:9a1865214ee0 | 1 | #include "mbed.h" |
| edumana | 0:9a1865214ee0 | 2 | |
| edumana | 0:9a1865214ee0 | 3 | Serial pc(USBTX, USBRX); |
| edumana | 0:9a1865214ee0 | 4 | |
| edumana | 0:9a1865214ee0 | 5 | void pr(volatile uint32_t *reg); |
| edumana | 0:9a1865214ee0 | 6 | |
| edumana | 0:9a1865214ee0 | 7 | int main(){ |
| edumana | 0:9a1865214ee0 | 8 | |
| edumana | 0:9a1865214ee0 | 9 | PORTA_PCR1 = 0x143; //Sets pin to GPIO |
| edumana | 0:9a1865214ee0 | 10 | PORTA_PCR2 = 0x143; //Sets pin to GPIO |
| edumana | 0:9a1865214ee0 | 11 | GPIOA_PDDR = 0x6; //Sets pin to output |
| edumana | 0:9a1865214ee0 | 12 | GPIOA_PSOR = 0x2; //Turns RED off, Leaves GREEN on |
| edumana | 0:9a1865214ee0 | 13 | |
| edumana | 0:9a1865214ee0 | 14 | while (1){ |
| edumana | 0:9a1865214ee0 | 15 | int volatile counter = 0; |
| edumana | 0:9a1865214ee0 | 16 | while(counter < 10000000){ |
| edumana | 0:9a1865214ee0 | 17 | counter++; |
| edumana | 0:9a1865214ee0 | 18 | } |
| edumana | 0:9a1865214ee0 | 19 | GPIOA_PTOR = 0x6; //Toggles 0110, RED and GREEN LEDs |
| edumana | 0:9a1865214ee0 | 20 | } |
| edumana | 0:9a1865214ee0 | 21 | } |
| edumana | 0:9a1865214ee0 | 22 | //Print Register: pr |
| edumana | 0:9a1865214ee0 | 23 | void pr(volatile uint32_t *reg){ |
| edumana | 0:9a1865214ee0 | 24 | pc.printf("%x --> %x \n", reg, *reg); |
| edumana | 0:9a1865214ee0 | 25 | } |