凌阳16位单片机之外部中断
时间:11-20
来源:互联网
点击:
实现功能:利用外部中断来控制8个发光二极管的点亮与熄灭,利用键盘产生外部中断触发信号。
#include "SPCE061A.H"
unsigned int output=0;
void IRQ3(void)__attribute__((ISR));
void IRQ3()
{
unsigned int delay;
*P_IOA_Data = 0x00ff;
if(*P_INT_Ctrl & C_IRQ3_EXT1)
{
*P_IOA_Data = 0x000f;
delay = 0x7fff;
while(delay--);
*P_INT_Clear = C_IRQ3_EXT1;
}
else if(*P_INT_Ctrl & C_IRQ3_EXT2)
{
*P_IOA_Data = 0x00f0;
delay = 0x7fff;
while(delay--);
*P_INT_Clear = C_IRQ3_EXT2;
}
else
{
*P_INT_Clear = C_IRQ3_KEY;
}
}
int main()
{
asm("INT OFF");
*P_IOA_Dir = 0x00ff;
*P_IOA_Attrib = 0x00ff;
*P_IOA_Data = 0x0000;
*P_IOB_Dir = 0x0000;
*P_IOB_Attrib = 0x0000;
*P_IOB_Data = 0x0008+0x0004;
*P_INT_Ctrl = C_IRQ3_EXT1 + C_IRQ3_EXT2;
asm("INT IRQ");
while(1)
{
*P_Watchdog_Clear = 0x0001;
}
}
实验现象:当按S20键时,D8~D11四个发光二极管点亮,当按S21键时,D4~D7四个发光二极管点亮。
#include "SPCE061A.H"
unsigned int output=0;
void IRQ3(void)__attribute__((ISR));
void IRQ3()
{
unsigned int delay;
*P_IOA_Data = 0x00ff;
if(*P_INT_Ctrl & C_IRQ3_EXT1)
{
*P_IOA_Data = 0x000f;
delay = 0x7fff;
while(delay--);
*P_INT_Clear = C_IRQ3_EXT1;
}
else if(*P_INT_Ctrl & C_IRQ3_EXT2)
{
*P_IOA_Data = 0x00f0;
delay = 0x7fff;
while(delay--);
*P_INT_Clear = C_IRQ3_EXT2;
}
else
{
*P_INT_Clear = C_IRQ3_KEY;
}
}
int main()
{
asm("INT OFF");
*P_IOA_Dir = 0x00ff;
*P_IOA_Attrib = 0x00ff;
*P_IOA_Data = 0x0000;
*P_IOB_Dir = 0x0000;
*P_IOB_Attrib = 0x0000;
*P_IOB_Data = 0x0008+0x0004;
*P_INT_Ctrl = C_IRQ3_EXT1 + C_IRQ3_EXT2;
asm("INT IRQ");
while(1)
{
*P_Watchdog_Clear = 0x0001;
}
}
凌阳16位单片机外部中 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)