powerdown.c
来自「ADI公司的ARM7的功能模块的源码」· C语言 代码 · 共 79 行
C
79 行
/*********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : Jun. 05
File : PowerDown.c
Hardware : ADuC7026
Description : The part is powered down by writing 0x40 to the POWCON
register. The part is then inactive until XIRQ is pressed.
This causes an interrupt to occur. Once the interupt
routine has been executed, the part reamins powered on and
runs as normal.
Note: P1.4 must be tied to groun to prevent it causing a
continuous interupt.
Another example in the timers folder shows power down mode
and wake up using the wake up timer.
*********************************************************************/
#include <ADuC7026.h> // Include ADuC7026 Header File
void My_IRQ_Function(void); // IRQ Funtion Prototype
void delay(int);
// Memory function macro
int main (void) {
IRQ = My_IRQ_Function; // Specify Interrupt Service Rountine
IRQEN = WAKEUP_TIMER_BIT;//XIRQ0_BIT|SPM4_IO_BIT; // Enable XIRQ0 in IRQEnable
T2CON = 0x4C0;
T2LD = 0x800;
GP0CON = 0x00;
GP4DAT = 0x04000000; // Configure P4.2 as output
GP2DAT = 0xff000000; // Configure port 2 as output
POWKEY1 = 0x01;
POWCON = 0x30;//0x40;
POWKEY2 = 0xF4;
while(1)
{
GP2DAT ^= 0x00ff0000; // Complement Port 2
delay(10000); // Delay to make blink visible
}
return 0 ;
}
/********************************************************************/
/* */
/* Interrupt Service Rountine */
/* */
/********************************************************************/
void My_IRQ_Function()
{
GP4DAT ^= 0x00040000; // Complement P4.2
POWKEY1 = 0x01;
POWCON = 0x30;//0x40;
POWKEY2 = 0xF4;
//while(GP0DAT & 0x00010){} // wait for XIRQ to be low again
return ;
}
void delay (int length)
{
while (length >=0)
length--;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?