#define Key_5 (volatile unsigned int *)0x0008 //5键
#define Key_6 (volatile unsigned int *)0x0004 //6键
#define Key_1 (volatile unsigned int *)0x000c //1键
#define Key_2 (volatile unsigned int *)0x0002 //2键
#define Key_3 (volatile unsigned int *)0x000a //3键
#define Key_4 (volatile unsigned int *)0x0006 //4键
#define Key_7 (volatile unsigned int *)0x000e //7键
#define Key_8 (volatile unsigned int *)0x0001 //8键
#include "hardware.h"
#include "s480.h"
unsigned int KeyFlag=0; //当前按键的状态,1有效
unsigned int KeyState=0; //遥控输入
void PlayRespond(int Result) //发音子函数的定义
www.751com.cn
ACM_S480_Stop();
}
//主程序开始
main()
{
//初始化;
InitIOA(); //初始化A口
InitIOB(); //初始化B口
INT1kHzON(); //开启1KHz中断
SACM_S480_Initial(1); //初始化SACM_S480
//循环等待按键
while(1)
{
switch(KeyState)
{
case Key_5:
PlayRespond(5);
break;
case Key_6:
PlayRespond(6);
break;
case Key_1:
PlayRespond(1);
break;
case Key_2:
PlayRespond(2);
break;
case Key_3:
PlayRespond(3);
break;
case Key_4:
PlayRespond(4);
break;
case Key_7:
PlayRespond(7);
break;
case Key_8:
PlayRespond(8);
break;
}
}
INT1kHzOFF(); //关闭1KHz中断
}
3.5中断服务程序设计
3.5.1中断程序流程
SPACE061A中断源列表
3.5.2中断服务程序编码
.INCLUDE hardware.inc
.INCLUDE Resource.inc
.include s480.inc
.DEFINE RUN_1kHz_TimeBase_INT 0x0010 //遥控输入
.EXTERNAL _GTime
.EXTERNAL _KeyFlag
.EXTERNAL _KeyState
.EXTERNAL R_InterruptStatus
.PUBLIC _FIQ,_BREAK,_IRQ0, _IRQ1, _IRQ2, _IRQ3, _IRQ4, _IRQ5, _IRQ6, _IRQ7
.code
.PUBLIC _INT1kHzOFF
_INT1kHzOFF:.proc
int off
R1 = 0xffff
[P_INT_Clear] = R1 // Clear interrupt occuiped events
R1 = [R_InterruptStatus] //
R1 &= 0xffef // Disenable 1kHz IRQ
[R_InterruptStatus] = R1 //
[P_INT_Ctrl] = R1 //
int irq
retf
.endp
.TEXT
_FIQ:
PUSH R1,R4 to [sp];
R1 = 0x0001;
[P_Watchdog_Clear] = R1;
R1 = 0x2000;
test R1,[P_INT_Ctrl];
jnz L_FIQ_TimerA;
R1 = 0x0800;
test R1,[P_INT_Ctrl];
jnz L_FIQ_TimerB;
L_FIQ_PWM:
R1 = C_FIQ_PWM;
[P_INT_Clear] = R1;
POP R1,R4 from[sp];
reti;
L_FIQ_TimerA:
[P_INT_Clear] = R1;
call F_FIQ_Service_SACM_S480;
pop R1,R4 from [sp];
RETI;
L_FIQ_TimerB:
[P_INT_Clear] = R1;
pop R1,R4 from [sp];
RETI;
_BREAK:
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>