?? powerdown.c
字號:
/*********************************************************************
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 + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -