; generated by ARM/Thumb C/C++ Compiler with , RVCT3.1 [Build 919] for uVision
; commandline ArmCC [--debug -c --asm --interleave -omain.o --depend=main.d --device=DARMP --apcs=interwork -O0 -IC:\Keil\ARM\INC\Philips --omf_browse=main.crf main.C]
ARM
AREA ||.text||, CODE, READONLY, ALIGN=2
WaitKey PROC
;;;9
;;;10 while(1)
000000 ea00000f B |L1.68|
|L1.4|
;;;11 { while( (IO0PIN&KEY1)!=0 ); // 等待KEY1键按下
000004 e1a00000 MOV r0,r0
|L1.8|
000008 e59f10ec LDR r1,|L1.252|
00000c e5911000 LDR r1,[r1,#0]
000010 e3110601 TST r1,#0x100000
000014 1afffffb BNE |L1.8|
;;;12 for(i=0; i<50000; i++); // 延时去抖
000018 e3a00000 MOV r0,#0
00001c ea000000 B |L1.36|
|L1.32|
000020 e2800001 ADD r0,r0,#1
|L1.36|
000024 e59f10d4 LDR r1,|L1.256|
000028 e1500001 CMP r0,r1
00002c 3afffffb BCC |L1.32|
;;;13 if( (IO0PIN&KEY1)==0 ) break;
000030 e59f10c4 LDR r1,|L1.252|
000034 e5911000 LDR r1,[r1,#0]
000038 e3110601 TST r1,#0x100000
00003c 1a000000 BNE |L1.68|
000040 ea000000 B |L1.72|
|L1.68|
000044 eaffffee B |L1.4|
|L1.72|
000048 e1a00000 MOV r0,r0
;;;14 }
;;;15
;;;16 while( (IO0PIN&KEY1)==0 ); // 等待KEY1键放开
00004c e1a00000 MOV r0,r0
|L1.80|
000050 e59f10a4 LDR r1,|L1.252|
000054 e5911000 LDR r1,[r1,#0]
000058 e3110601 TST r1,#0x100000
00005c 0afffffb BEQ |L1.80|
;;;17 }
000060 e12fff1e BX lr
;;;18 /****************************************************************************
ENDP
PWM_Init PROC
;;;25 {
;;;26 PWMPR = 0x00; // 不分频,计数频率为Fpclk
000064 e3a00000 MOV r0,#0
000068 e59f1094 LDR r1,|L1.260|
00006c e581000c STR r0,[r1,#0xc]
;;;27 PWMMCR = 0x02; // 设置PWMMR0匹配时复位PWMTC
000070 e3a00002 MOV r0,#2
000074 e5810014 STR r0,[r1,#0x14]
;;;28 PWMMR0 = 3000; // 设置PWM周期,PWMMR0=2765
000078 e59f0088 LDR r0,|L1.264|
00007c e5810018 STR r0,[r1,#0x18]
;;;29 PWMMR2 = 1500; // 设置PWM占空比,PWMMR6=1382
000080 e1a000c0 ASR r0,r0,#1
000084 e5810020 STR r0,[r1,#0x20]
;;;30 PWMLER = 0x05; // PWMMR0、PWMMR2锁存 //0x41 /0x05
000088 e3a00005 MOV r0,#5
00008c e5810050 STR r0,[r1,#0x50]
;;;31 PWMPCR = 0X0400; // 允许PWM2输出,单边PWM //0x40000 /0x0400
000090 e3a00b01 MOV r0,#0x400
000094 e581004c STR r0,[r1,#0x4c]
;;;32 PWMTCR = 0x09; // 启动定时器,PWM使能
000098 e3a00009 MOV r0,#9
00009c e5810004 STR r0,[r1,#4]
;;;33 }
0000a0 e12fff1e BX lr
;;;34 /********************************************************************/
ENDP
main PROC
;;;45 int main(void)
;;;46 {
0000a4 e52de004 PUSH {lr}
;;;47 //TargetResetInit();
;;;48 uint32 pwmdata; // PWM占空比控制变量
;;;49
;;;50 PINSEL0 = 0x00008000; // 设置PWM2连接到P0.7管脚
0000a8 e3a00902 MOV r0,#0x8000
0000ac e59f1058 LDR r1,|L1.268|
0000b0 e5810000 STR r0,[r1,#0]
;;;51 PINSEL1 = 0x00000000; // 其它管脚设置为GPIO
0000b4 e3a00000 MOV r0,#0
0000b8 e5810004 STR r0,[r1,#4]
;;;52
;;;53 PWM_Init(); // PWM初始化
0000bc ebfffffe BL PWM_Init
;;;54
;;;55 pwmdata = DUTY_CYCLE_DATA;
0000c0 e3a02064 MOV r2,#0x64
;;;56 while(1)
0000c4 ea00000b B |L1.248|
|L1.200|
;;;57 {
;;;58 PWMMR0 = CYCLE_DATA; // 设置PWM周期,PWMMR0=CYCLE_DATA
0000c8 e3a00e7d MOV r0,#0x7d0
0000cc e59f1030 LDR r1,|L1.260|
0000d0 e5810018 STR r0,[r1,#0x18]
;;;59 PWMMR2 = pwmdata; // 设置PWM占空比,PWMMR6=pwmdata
0000d4 e1c10000 BIC r0,r1,r0
0000d8 e5802020 STR r2,[r0,#0x20]
;;;60 PWMLER = 0x05; // PWMMR0、PWMMR2锁存,更新PWM占空比/0x41 0x05
0000dc e3a00005 MOV r0,#5
0000e0 e5810050 STR r0,[r1,#0x50]
;;;61 //while(1);
;;;62 WaitKey();
0000e4 ebfffffe BL WaitKey
;;;63 pwmdata += 400;
0000e8 e2822e19 ADD r2,r2,#0x190
;;;64 if(pwmdata>CYCLE_DATA) pwmdata=0;
0000ec e3520e7d CMP r2,#0x7d0
0000f0 9a000000 BLS |L1.248|
0000f4 e3a02000 MOV r2,#0
|L1.248|
0000f8 eafffff2 B |L1.200|
;;;65
;;;66
;;;67 }
;;;68 }
ENDP
|L1.252|
0000fc e0028000 DCD 0xe0028000
|L1.256|
000100 0000c350 DCD 0x0000c350
|L1.260|
000104 e0014000 DCD 0xe0014000
|L1.264|
000108 00000bb8 DCD 0x00000bb8
|L1.268|
00010c e002c000 DCD 0xe002c000
__ARM_use_no_argv EQU 0
评论0