psm.c
字号:
/*********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : Sept. 2005
File : PSM.c
Hardware : Applicable to ADuC702x rev H or I silicon
Currently targetting ADuC7026.
Description : the PSM produces an interrupt when the supply goes below 3.07V
*********************************************************************/
#include<aduc7026.h>
void delay(int);
void My_IRQ_Function(void); // IRQ Funtion Prototype
int main(void){
IRQ = My_IRQ_Function; // Specify Interrupt Service Rountine
GP4DAT = 0x04000000; // P4.2 configured as an output. LED is turned on
PSMCON = 0x6; // trip point of 3.07V
IRQEN = PSM_BIT; // Enable PSM in IRQEnable
while (1){
delay(200000);
}
}
/********************************************************************/
/* */
/* Interrupt Service Rountine */
/* */
/********************************************************************/
void My_IRQ_Function(){
if ((IRQSTA & PSM_BIT) != 0){
while (!(PSMCON&0x8)){} // Check that the level is back to normal
PSMCON = 0x7; // Clear interrupt
GP4DAT ^= 0x00040000; // Complement P4.2
}
return ;
}
void delay (int length) {
while (length >=0)
length--;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -