📄 xirq0.c
字号:
/*********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : October 2006
File : XIRQ0.c
Hardware : Applicable to ADuC7020/ADuC7024/ADuC7026
Currently targetting the ADuC7024
Description : Complement port 3 in a loop.
When XIRQ0 is pressed, complement P4.2
*********************************************************************/
#include <Analogdevices/ioaduc7024.h> // Include ADuC7024 Header File
#include <intrinsics.h>
__irq __arm void IRQ_Handler(void); // IRQ Function Prototype
void delay(int);
// IMPORTANT - The amount of stack spaces allocated for the IRQ stack is
// defined by __ICFEDIT_size_irqstack__ in the linker script file.
// If you add additional function calls or additional local
// variables then you should verify that __ICFEDIT_size_irqstack__
// is still sufficiently large to prevent overflow of the stack and
// corruption of data
// All default exception handlers (except reset) are defined as weak
// symbol definitions.
// If a handler is defined by the application it will take precedence.
__irq __arm void IRQ_Handler(void) // IRQ Handler
{
GP4DAT ^= 0x04040000; // Complement P4.2
while(GP0DAT & 0x00010){} // wait for XIRQ to be low again
return ;
}
// IMPORTANT - The amount of stack spaces allocated for the FIQ stack is
// defined by __ICFEDIT_size_fiqstack__ in the linker script file.
// If you add additional function calls or additional local
// variables then you should verify that __ICFEDIT_size_fiqstack__
// is still sufficiently large to prevent overflow of the stack and
// corruption of data
// All default exception handlers (except reset) are defined as weak
// symbol definitions.
// If a handler is defined by the application it will take precedence.
__fiq __arm void FIQ_Handler(void) // fiq Handler
{
// Replace this while (1) code with a proper handler for the fiq source
while (1);
}
int main (void)
{
IRQEN = XIRQ0_BIT; // Enable XIRQ0 in IRQEnable
GP0CON = 0x00;
GP4DAT = 0x04000000; // Configure P4.2 as output
GP3DAT = 0xff000000; // Configure port 3 as output
#ifdef USE_REMAP // Have RAM at 0x0 instead of flash?
REMAP = 0x1;
#endif
__enable_interrupt(); // Enable interrupts
while(1)
{
GP3DAT ^= 0x00ff0000; // Complement Port 3
delay(900000); // Delay to make blink visible
}
}
void delay (int length) // Delay function
{
while (length >=0)
length--;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -