📄 demo.lst
字号:
ARM COMPILER V2.53, demo 05/09/06 14:20:50 PAGE 1
ARM COMPILER V2.53, COMPILATION OF MODULE demo
OBJECT MODULE PLACED IN .\Obj\demo.obj
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe demo.c THUMB DEBUG PRINT(.\LST\DEMO.LST) TABS(4) OBJECT(.\Obj\demo.obj)
stmt level source
1 /*----------------------------------------------------------------------------
2 * Name: DEMO.C
3 * Purpose: USB Audio Demo
4 * Version: V1.10
5 *----------------------------------------------------------------------------
6 * This software is supplied "AS IS" without any warranties, express,
7 * implied or statutory, including but not limited to the implied
8 * warranties of fitness for purpose, satisfactory quality and
9 * noninfringement. Keil extends you a royalty-free right to reproduce
10 * and distribute executable files created using this software for use
11 * on Philips LPC2xxx microcontroller devices only. Nothing else gives
12 * you the right to use this software.
13 *
14 * Copyright (c) 2005-2006 Keil Software.
15 *---------------------------------------------------------------------------*/
16
17 #include <LPC214X.H> /* LPC214x definitions */
18
19 #include "type.h"
20
21 #include "usb.h"
22 #include "usbcfg.h"
23 #include "usbhw.h"
24 #include "usbcore.h"
25
26 #include "demo.h"
27
28
29 BYTE Mute; /* Mute State */
30 DWORD Volume; /* Volume Level */
31
32 #if USB_DMA
DWORD InfoBuf[P_C] __at DMA_BUF_ADR; /* Packet Info Buffer */
short DataBuf[B_S] __at (DMA_BUF_ADR+4*P_C);/* Data Buffer */
#else
36 short DataBuf[B_S]; /* Data Buffer */
37 #endif
38
39 WORD DataOut; /* Data Out Index */
40 WORD DataIn; /* Data In Index */
41
42 BYTE DataRun; /* Data Stream Run State */
43
44 WORD PotVal; /* Potenciometer Value */
45
46 DWORD VUM; /* VU Meter */
47
48 DWORD Tick; /* Time Tick */
49
50
51 /*
52 * Get Potenciometer Value
53 */
54
55 void get_potval (void) {
56 1 DWORD val;
57 1
58 1 AD0CR |= 0x01000000; /* Start A/D Conversion */
59 1 do {
ARM COMPILER V2.53, demo 05/09/06 14:20:50 PAGE 2
60 2 val = AD0GDR; /* Read A/D Data Register */
61 2 } while ((val & 0x80000000) == 0); /* Wait for end of A/D Conversion */
62 1 AD0CR &= ~0x01000000; /* Stop A/D Conversion */
63 1 PotVal = ((val >> 8) & 0xF8) + /* Extract Potenciometer Value */
64 1 ((val >> 7) & 0x08);
65 1 }
66
67
68 /*
69 * Timer Counter 0 Interrupt Service Routine
70 * executed each 31.25us (32kHz frequency)
71 */
72
73 void tc0_isr (void) __irq {
74 1 long val;
75 1 DWORD cnt;
76 1
77 1 if (DataRun) { /* Data Stream is running */
78 2 val = DataBuf[DataOut]; /* Get Audio Sample */
79 2 cnt = (DataIn - DataOut) & (B_S - 1); /* Buffer Data Count */
80 2 if (cnt == (B_S - P_C*P_S)) { /* Too much Data in Buffer */
81 3 DataOut++; /* Skip one Sample */
82 3 }
83 2 if (cnt > (P_C*P_S)) { /* Still enough Data in Buffer */
84 3 DataOut++; /* Update Data Out Index */
85 3 }
86 2 DataOut &= B_S - 1; /* Adjust Buffer Out Index */
87 2 if (val < 0) VUM -= val; /* Accumulate Neg Value */
88 2 else VUM += val; /* Accumulate Pos Value */
89 2 val *= Volume; /* Apply Volume Level */
90 2 val >>= 16; /* Adjust Value */
91 2 val += 0x8000; /* Add Bias */
92 2 val &= 0xFFFF; /* Mask Value */
93 2 } else {
94 2 val = 0x8000; /* DAC Middle Point */
95 2 }
96 1
97 1 if (Mute) {
98 2 val = 0x8000; /* DAC Middle Point */
99 2 }
100 1
101 1 DACR = val & 0xFFC0; /* Set Speaker Output */
102 1
103 1 if ((Tick++ & 0x03FF) == 0) { /* On every 1024th Tick */
104 2 get_potval(); /* Get Potenciometer Value */
105 2 if (VolCur == 0x8000) { /* Check for Minimum Level */
106 3 Volume = 0; /* No Sound */
107 3 } else {
108 3 Volume = VolCur * PotVal; /* Chained Volume Level */
109 3 }
110 2 val = VUM >> 20; /* Scale Accumulated Value */
111 2 VUM = 0; /* Clear VUM */
112 2 if (val > 7) val = 7; /* Limit Value */
113 2 IOCLR1 = LEDMSK; /* Turn Off all LEDs */
114 2 IOSET1 = LEDMSK >> (7 - val); /* LEDs show VU Meter */
115 2 }
116 1
117 1 T0IR = 1; /* Clear Interrupt Flag */
118 1 VICVectAddr = 0; /* Acknowledge Interrupt */
119 1 }
120
121
122 /* Main Program */
123
124 int main (void) {
125 1
ARM COMPILER V2.53, demo 05/09/06 14:20:50 PAGE 3
126 1 PINSEL1 = 0x01080000; /* Select AOUT,AIN1 */
127 1 IODIR1 = LEDMSK; /* LED's defined as Outputs */
128 1
129 1 AD0CR = 0x00200E02; /* ADC: 10-bit AIN1 @ 4MHz */
130 1 DACR = 0x00008000; /* DAC Output set to Middle Point */
131 1
132 1 /* Setup Timer Counter 0: Periodic Timer with Interrupt at DATA_FREQ Rate */
133 1 T0MR0 = VPB_CLOCK/DATA_FREQ - 1; /* TC0 Match Value 0 */
134 1 T0MCR = 3; /* TCO Interrupt and Reset on MR0 */
135 1 T0TCR = 1; /* TC0 Enable */
136 1
137 1 /* Setup Timer Counter 0 Interrupt */
138 1 VICVectAddr1 = (unsigned long)tc0_isr; /* TC0 Interrupt -> Vector 1 */
139 1 VICVectCntl1 = 0x20 | 4; /* TC0 Interrupt -> IRQ Slot 1 */
140 1 VICIntEnable = 1 << 4; /* Enable TC0 Interrupt */
141 1
142 1 USB_Init(); /* USB Initialization */
143 1 USB_Connect(TRUE); /* USB Connect */
144 1
145 1 while (1); /* Loop forever */
146 1 }
ARM COMPILER V2.53, demo 05/09/06 14:20:50 PAGE 4
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN CODE16 (USB_Init?T)
EXTERN CODE16 (USB_Connect?T)
EXTERN DATA (VolCur)
EXTERN NUMBER (__startup)
*** PUBLICS:
PUBLIC get_potval?T
PUBLIC get_potval?A
PUBLIC tc0_isr?A
PUBLIC main
PUBLIC Mute
PUBLIC Volume
PUBLIC DataBuf
PUBLIC DataOut
PUBLIC DataIn
PUBLIC DataRun
PUBLIC PotVal
PUBLIC VUM
PUBLIC Tick
*** DATA SEGMENT '?DT0?demo':
00000000 Volume:
00000000 DS 4
00000004 VUM:
00000004 DS 4
00000008 Tick:
00000008 DS 4
0000000C DataBuf:
0000000C DS 512
0000020C DataOut:
0000020C DS 2
0000020E DataIn:
0000020E DS 2
00000210 PotVal:
00000210 DS 2
00000212 Mute:
00000212 DS 1
00000213 DataRun:
00000213 DS 1
*** CODE SEGMENT '?PR?get_potval?T?demo':
55: void get_potval (void) {
00000000 ; SCOPE-START
58: AD0CR |= 0x01000000; /* Start A/D Conversion */
00000000 4800 LDR R2,=0x1000000
00000002 4800 LDR R0,=0xE0034000
00000004 6801 LDR R1,[R0,#0x0]
00000006 4311 ORR R1,R2
00000008 6001 STR R1,[R0,#0x0]
59: do {
0000000A L_1:
60: val = AD0GDR; /* Read A/D Data Register */
0000000A 4800 LDR R0,=0xE0034004
0000000C 6802 LDR R2,[R0,#0x0]
0000000E ---- Variable 'val' assigned to Register 'R2' ----
61: } while ((val & 0x80000000) == 0); /* Wait for end of A/D Conversion */
0000000E 1C10 MOV R0,R2 ; val
00000010 4800 LDR R1,=0x80000000
00000012 4208 TST R0,R1 ; val
00000014 D0F9 BEQ L_1 ; T=0x0000000A
62: AD0CR &= ~0x01000000; /* Stop A/D Conversion */
00000016 4800 LDR R3,=0x1000000
ARM COMPILER V2.53, demo 05/09/06 14:20:50 PAGE 5
00000018 4800 LDR R0,=0xE0034000
0000001A 6801 LDR R1,[R0,#0x0]
0000001C 4399 BIC R1,R3
0000001E 6001 STR R1,[R0,#0x0]
63: PotVal = ((val >> 8) & 0xF8) + /* Extract Potenciometer Value */
00000020 1C10 MOV R0,R2 ; val
00000022 09C0 LSR R0,R0,#0x7 ; val
00000024 2108 MOV R1,#0x8
00000026 4008 AND R0,R1
00000028 1C11 MOV R1,R2 ; val
0000002A 0A09 LSR R1,R1,#0x8 ; val
0000002C 22F8 MOV R2,#0xF8
0000002E 4011 AND R1,R2
00000030 1809 ADD R1,R0
00000032 0409 LSL R1,R1,#0x10
00000034 0C09 LSR R1,R1,#0x10
00000036 4800 LDR R0,=PotVal ; PotVal
00000038 8001 STRH R1,[R0,#0x0] ; PotVal
0000003A ; SCOPE-END
65: }
0000003A 4770 BX R14
0000003C ENDP ; 'get_potval?T'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -