1 | /****************************************************************************
|
2 | * $Id:: tmrtest.c 6098 2011-01-08 02:26:20Z nxp12832 $
|
3 | * Project: NXP LPC17xx Timer example
|
4 | *
|
5 | * Description:
|
6 | * This file contains Timer test modules, main entry, to test Timer APIs.
|
7 | *
|
8 | ****************************************************************************
|
9 | * Software that is described herein is for illustrative purposes only
|
10 | * which provides customers with programming information regarding the
|
11 | * products. This software is supplied "AS IS" without any warranties.
|
12 | * NXP Semiconductors assumes no responsibility or liability for the
|
13 | * use of the software, conveys no license or title under any patent,
|
14 | * copyright, or mask work right to the product. NXP Semiconductors
|
15 | * reserves the right to make changes in the software without
|
16 | * notification. NXP Semiconductors also make no representation or
|
17 | * warranty that such application will be suitable for the specified
|
18 | * use without further testing or modification.
|
19 | ****************************************************************************/
|
20 | #include <cr_section_macros.h>
|
21 | #include <NXP/crp.h>
|
22 |
|
23 | __CRP const unsigned int CRP_WORD = CRP_NO_CRP ;
|
24 |
|
25 | #include "lpc17xx.h"
|
26 | #include "type.h"
|
27 | #include "timer.h"
|
28 |
|
29 | #define BLINK_INTERVAL 20
|
30 |
|
31 | extern uint32_t timer0_m0_counter, timer1_m0_counter;
|
32 | extern uint32_t timer0_m1_counter, timer1_m1_counter;
|
33 |
|
34 | /*****************************************************************************
|
35 | ** Main Function main()
|
36 | *****************************************************************************/
|
37 | int main (void)
|
38 | {
|
39 | uint32_t i;
|
40 |
|
41 | /* SystemClockUpdate() updates the SystemFrequency variable */
|
42 | SystemClockUpdate();
|
43 |
|
44 | LPC_GPIO2->FIODIR = 0x000000FF; /* P2.0..7 defined as Outputs */ //Geändert aufP2.0...5
|
45 | LPC_GPIO2->FIOCLR = 0x000000FF; /* turn off all the LEDs */
|
46 |
|
47 | for ( i = 0; i < 2; i++ )
|
48 | {
|
49 | init_timer( i , TIME_INTERVAL );
|
50 | enable_timer( i );
|
51 | }
|
52 |
|
53 | /* Loop forever */
|
54 | while (1)
|
55 | { /* Loop forever */
|
56 | if ( (timer0_m0_counter > 0) && (timer0_m0_counter <= BLINK_INTERVAL) )
|
57 | {
|
58 | LPC_GPIO2->FIOSET = 1 << 2;
|
59 | }
|
60 | if ( (timer0_m0_counter > BLINK_INTERVAL) && (timer0_m0_counter <= (BLINK_INTERVAL * 2)) )
|
61 | {
|
62 | LPC_GPIO2->FIOCLR = 1 << 2;
|
63 | }
|
64 | else if ( timer0_m0_counter > (BLINK_INTERVAL * 2) )
|
65 | {
|
66 | timer0_m0_counter = 0;
|
67 | }
|
68 | /* Timer 1 blinky LED 1 */
|
69 | if ( (timer1_m0_counter > 0) && (timer1_m0_counter <= BLINK_INTERVAL) )
|
70 | {
|
71 | LPC_GPIO2->FIOSET = 1 << 3;
|
72 | }
|
73 | if ( (timer1_m0_counter > BLINK_INTERVAL) && (timer1_m0_counter <= (BLINK_INTERVAL * 2)) )
|
74 | {
|
75 | LPC_GPIO2->FIOCLR = 1 << 3;
|
76 | }
|
77 | else if ( timer1_m0_counter > (BLINK_INTERVAL * 2) )
|
78 | {
|
79 | timer1_m0_counter = 0;
|
80 | }
|
81 | }
|
82 | }
|
83 |
|
84 | /*****************************************************************************
|
85 | ** End Of File
|
86 | ******************************************************************************/
|