凌陽16位單片機之FIQ中斷
實驗現(xiàn)象:TimerA定時長度為2s,當進入TimerA的FIQ中斷后,翻轉(zhuǎn)IOA口低四位的輸出電平以控制接在IOA低四位端口的發(fā)光二極管;TimerB定時長度為1s,當進入TimerB的FIQ中斷后,翻轉(zhuǎn)IOB口低四位的輸出電平以控制接在IOB低四位端口的發(fā)光二極管。程序運行時,可以觀察到接在IOA低四位端口的發(fā)光二極管亮滅的周期為4s,而接在IOB低四位端口的為2s。
本文引用地址:http://2s4d.com/article/201611/318711.htm
#include "SPCE061A.H"
unsigned int n,Output1=0x00f0,Output2=0x000f;
void FIQ(void)__attribute__((ISR));
void FIQ()
{
if(*P_INT_Ctrl&0x2000)//當是TimerA中斷是b13
{
*P_INT_Clear = 0x2000;
Output1^=0xffff;
*P_IOA_Data = Output1;
}
if(*P_INT_Ctrl&0x0800)//當是TimerB中斷是b11
{
*P_INT_Clear = 0x0800;
Output2^=0xffff;
*P_IOA_Data = Output2;
}
}
int main()
{
__asm("FIQ OFF");
*P_IOA_Dir = 0x00ff;
*P_IOA_Attrib = 0x00ff;
*P_IOA_Data = 0x0000;
*P_TimerA_Ctrl = 0x000d;//選擇了1024HZ的
*P_TimerA_Data = 0xffff-2048;
*P_TimerB_Ctrl = 0x0004;//選擇了4096的
*P_TimerB_Data = 0xffff-4096;
*P_INT_Ctrl = 0x2800;
__asm("FIQ ON");
while(1)
{
*P_Watchdog_Clear = 0x0001;
}
}
評論