📄 blinky.lst
字号:
ARM COMPILER V2.53, Blinky 13/07/06 17:34:35 PAGE 1
ARM COMPILER V2.53, COMPILATION OF MODULE Blinky
OBJECT MODULE PLACED IN .\Flash\Blinky.obj
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe Blinky.c THUMB OPTIMIZE(7,SPEED) BROWSE DEBUG PRINT(.\FLASH\BLINKY.LST) TABS
-(4) OBJECT(.\Flash\Blinky.obj)
stmt level source
1 /******************************************************************************/
2 /* This file is part of the uVision/ARM development tools */
3 /* Copyright KEIL ELEKTRONIK GmbH 2002-2004 */
4 /******************************************************************************/
5 /* */
6 /* BLINKY.C: LED Flasher */
7 /* */
8 /******************************************************************************/
9
10 #include <stdio.h> /* standard I/O .h-file */
11 #include <LPC213x.H> /* LPC213x definitions */
12 #include <math.h>
13
14 extern void init_serial (void); /* Initialize Serial Interface */
15
16 int volatile timeval;
17
18 /*
19 * ----- Parameters and Variables for Sine Wave Generator -----
20 */
21
22 unsigned long OutFreq = 480l; /* Output Frequency (Range 1Hz - 4000Hz) */
23 #define OutAmpl 600 /* Output Amplitute (Range 0 - 0.99) */
24 #define PI 3.1415926
25 #define T0_RlFreq 8000 /* Timer 0 Reload Frequency */
26
27 struct tone { /* struct for Sine Wave Generator Signal */
28 int cos; /* cosine factor */
29 long y1; /* y[-1] value */
30 int y2; /* y[-2] value */
31 };
32
33 int NewFreq; /* New Frequency Setup indication */
34
35 short tval;
36 signed char cval;
37 struct tone Tone;
38
39 /*
40 * Generate Sine Wave Tone
41 */
42 static void Generate_Sine (struct tone *t) {
43 1 int y;
44 1 y = (t->cos * (t->y1 >> 14)) - t->y2;
45 1 t->y2 = t->y1;
46 1 t->y1 = y;
47 1 tval = t->y1 >> 16;
48 1 cval = tval;
49 1 }
50
51 /*
52 * Initialize the Sine Wave Tone Generator
53 */
54 static __inline void Init_Sine (int OutFreq) {
55 1 Tone.cos = (cos (2*PI*((float)OutFreq/T0_RlFreq))) * 32768;
56 1 Tone.y1 = 0;
57 1 Tone.y2 = (sin (2*PI*((float)OutFreq/T0_RlFreq)) * OutAmpl) * 32768;
58 1 }
ARM COMPILER V2.53, Blinky 13/07/06 17:34:35 PAGE 2
59
60 /* Timer Counter 0 Interrupt executes each 10ms @ 60 MHz CPU Clock */
61 void tc0 (void) __irq {
62 1 ++timeval;
63 1
64 1 if (NewFreq) { /* The frequency changes when a new ADC value is measured
- */
65 2 Init_Sine (NewFreq);
66 2 NewFreq = 0;
67 2 }
68 1
69 1 Generate_Sine (&Tone);
70 1 DACR = ((Tone.y1 >> 10) & 0xFFC0) + 0x8000;
71 1 T0IR = 1; /* Clear interrupt flag */
72 1 VICVectAddr = 0; /* Acknowledge Interrupt */
73 1
74 1 }
75
76 /* Setup the Timer Counter 0 Interrupt */
77 void init_timer (void) {
78 1 T0MR0 = 1874; /* 0.125uSec = 1875-1 counts */
79 1 T0MCR = 3; /* Interrupt and Reset on MR0 */
80 1 T0TCR = 1; /* Timer0 Enable */
81 1 VICVectAddr0 = (unsigned long)tc0; /* set interrupt vector in 0 */
82 1 VICVectCntl0 = 0x20 | 4; /* use it for Timer 0 Interrupt */
83 1 VICIntEnable = 0x00000010; /* Enable Timer0 Interrupt */
84 1 }
85
86
87 void sendhex (int hex) { /* Write Hex Digit to Serial Port */
88 1 if (hex > 9) putchar('A' + (hex - 10));
89 1 else putchar('0' + hex);
90 1 }
91
92 void sendstr (char *p) { /* Write string */
93 1 while (*p) {
94 2 putchar (*p++);
95 2 }
96 1 }
97
98 void delay (void) { /* Delay function */
99 1 unsigned int cnt;
100 1 unsigned int val;
101 1 static unsigned int oldval;
102 1 int diff;
103 1
104 1 AD0CR |= 0x01200000; /* Start A/D Conversion */
105 1 do {
106 2 val = AD0DR; /* Read A/D Data Register */
107 2 } while ((val & 0x80000000) == 0); /* Wait for end of A/D Conversion */
108 1 AD0CR &= ~0x01000000; /* Stop A/D Conversion */
109 1 val = (val >> 6) & 0x03FF; /* Extract AIN0 Value */
110 1
111 1 diff = val - oldval;
112 1 if (diff > 10 || diff < -10) {
113 2 oldval = val;
114 2 NewFreq = 1200 - val;
115 2 }
116 1
117 1 printf ("\nAIN0 Result = 0x%03X", val); /* Output A/D Conversion Result */
118 1
119 1 val = (val >> 2) << 12; /* Adjust Delay Value */
120 1 for (cnt = 0; cnt < val; cnt++); /* Delay */
121 1 }
122
123
ARM COMPILER V2.53, Blinky 13/07/06 17:34:35 PAGE 3
124 int main (void) {
125 1 unsigned int n;
126 1
127 1 IODIR2 = 0x00FF0000; /* P1.16..23 defined as Outputs */
*** ERROR C67 IN LINE 127 OF BLINKY.C: 'IODIR2': undefined identifier
128 1 //AD0CR = 0x00200402; /* Setup A/D: 10-bit AIN0 @ 3MHz */
129 1 //PINSEL1 = 0x01080000; /* enable DAC */
130 1
131 1 init_serial(); /* Initialize Serial Interface */
132 1 init_timer ();
133 1
134 1 while (1) { /* Loop forever */
135 2 for (n = 0x00000001; n <= 0x00000080; n <<= 1) {
136 3 /* Blink LED 0, 1, 2, 3, 4, 5, 6, 7 */
137 3 IOSET2 = n; /* Turn on LED */
*** ERROR C67 IN LINE 137 OF BLINKY.C: 'IOSET2': undefined identifier
138 3 // delay(); /* Delay */
139 3 IOCLR2 = 0x00FF0000; /* Turn off LEDs */
*** ERROR C67 IN LINE 139 OF BLINKY.C: 'IOCLR2': undefined identifier
140 3 }
141 2 }
142 1 }
ARM COMPILATION COMPLETE. 0 WARNING(S), 3 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -