Program which demonstrates the usage of the TIMER peripheral. Program sets TIMER 2 to blink the LED on the pin P0.9. This is a more sophisticated way of blinking an LED.
Dependencies: mbed
main.c@0:e83c998e1cfd, 2015-05-02 (annotated)
- Committer:
- 71GA
- Date:
- Sat May 02 17:25:32 2015 +0000
- Revision:
- 0:e83c998e1cfd
First commit of this program.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
71GA | 0:e83c998e1cfd | 1 | #include "LPC4088-ioconfig.h" |
71GA | 0:e83c998e1cfd | 2 | #include "LPC4088-gpio.h" |
71GA | 0:e83c998e1cfd | 3 | #include "LPC4088-timer.h" |
71GA | 0:e83c998e1cfd | 4 | #include "LPC4088-system.h" |
71GA | 0:e83c998e1cfd | 5 | |
71GA | 0:e83c998e1cfd | 6 | int main(){ |
71GA | 0:e83c998e1cfd | 7 | |
71GA | 0:e83c998e1cfd | 8 | //omogocimo timer 2, ki ob zagonu ni prizgan tako kot timerja 0,1 |
71GA | 0:e83c998e1cfd | 9 | PCONP = (PCONP | (1<<22)); |
71GA | 0:e83c998e1cfd | 10 | |
71GA | 0:e83c998e1cfd | 11 | //timer 2 izhod MAT3 preusmerimo na pin P0_9 |
71GA | 0:e83c998e1cfd | 12 | IOCON_P0_9 = (IOCON_P0_9 & !(0x7FF)); |
71GA | 0:e83c998e1cfd | 13 | IOCON_P0_9 = (IOCON_P0_9 | 0x183); |
71GA | 0:e83c998e1cfd | 14 | |
71GA | 0:e83c998e1cfd | 15 | //resetiramo vse interrupte za timer 2 |
71GA | 0:e83c998e1cfd | 16 | IR = (IR | 0x3F); |
71GA | 0:e83c998e1cfd | 17 | |
71GA | 0:e83c998e1cfd | 18 | //nastavimo izhod MAT3 na "toggle" |
71GA | 0:e83c998e1cfd | 19 | EMR = (EMR | (0x3<<10)); |
71GA | 0:e83c998e1cfd | 20 | |
71GA | 0:e83c998e1cfd | 21 | //match register 3 nastavimo na 1/4 najvecje vrednosti timerja 2 |
71GA | 0:e83c998e1cfd | 22 | MR1 = 0x3FFFFFFF; |
71GA | 0:e83c998e1cfd | 23 | |
71GA | 0:e83c998e1cfd | 24 | //omogocimo timer 2 |
71GA | 0:e83c998e1cfd | 25 | TCR = (TCR | (1<<0)); |
71GA | 0:e83c998e1cfd | 26 | |
71GA | 0:e83c998e1cfd | 27 | while(1); |
71GA | 0:e83c998e1cfd | 28 | |
71GA | 0:e83c998e1cfd | 29 | } |