首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

求助:LJ12的STOP低功耗模式使用问题

求助:LJ12的STOP低功耗模式使用问题

芯片:LJ12


   写了一个极其简单的程序:


1)主程序先开启RTC的minute interrupt,然后是一个死循环,循环体执行asm(“STOP”)语句。


2)中断服务程序也很简单,将MCU的一个IO取反,该IQ上连接了LED,这样可以看到LED的闪烁。


现象:


   上电执行程序,一分钟后,LED开始快速闪烁(明显不是一分钟闪烁一次)。


 


 


不知道问题出在哪里?

刚才又发现了新现象,上电一秒后,LED就一直亮着,证明中断服务程序只执行了一次。
STOP到RUN等于外部复位
Freescale代理--北高智 服务感动客户
那有没有办法用stop,还不用复位呢?中断之后回到stop之后继续运行。多谢指点
MCU从stop模式退出后,应该是从stop之后的指令执行
看看你是不是没有在configure寄存器中允许stop指令,是的stop为非法指令引起reset
我的MCU初始化函数如下:
void MCU_init(void)
{

/*** ### MC68HC908LJ12_64 "Cpu" init code ... ***/
/*** PE initialization code after reset ***/
/* System clock initialization */

/* Common initialization of the write once registers */
/* CONFIG1: COPRS=0,LVISTOP=0,LVIRSTD=0,LVIPWRD=1,SSREC=0,STOP=1,COPD=1 */
CONFIG1 = 0x13;
/* CONFIG2: STOP_IRCDIS=1,STOP_XCLKEN=1,DIV2CLK=0,PCEH=0,PCEL=0,LVISEL1=0,LVISEL0=0 */
CONFIG2 = 0x60;
/* Common initialization of the write once registers */
/* PCTL: BCS=0 */
PCTL &= (unsigned char)~0x10; /* Select clock source from XTAL */
/* PCTL: PLLON=0 */
PCTL &= (unsigned char)~0x20; /* Disable the PLL */
/* PCTL: PLLIE=0,PLLF=0,PLLON=0,BCS=0,PRE1=0,PRE0=0,VPR1=0,VPR0=0 */
PCTL = 0x00; /* Set VCO output Power-of-Two devider P=0 the VCO Power-of-Two multiplier E=0 */
/* PMS: MUL11=0,MUL10=0,MUL9=0,MUL8=0,MUL7=1,MUL6=1,MUL5=1,MUL4=1,MUL3=0,MUL2=1,MUL1=0,MUL0=0 */
PMS = 0xF4; /* Set the Feedback divider N=244 */
/* PMRS: VRS7=1,VRS6=1,VRS5=0,VRS4=1,VRS3=0,VRS2=0,VRS1=0,VRS0=0 */
PMRS = 0xD0; /* Set the VCO Linear multiplier L=208 */
/* PMDS: RDS3=0,RDS2=0,RDS1=0,RDS0=1 */
PMDS = 0x01; /* Set the Reference clock devider R=1 */
/* PBWC: AUTO=1,LOCK=0,ACQ=0 */
PBWC = 0x80; /* Select the operating modes */
/* PCTL: PLLON=1 */
PCTL |= (unsigned char)0x20; /* Enable the PLL */
while(!PBWC_LOCK) { /* Wait */
}
/* PCTL: BCS=1 */
PCTL |= (unsigned char)0x10; /* Select clock source from PLL */
__asm("nop");
__asm("nop");
/* Common initialization of the CPU registers */
/* LVISR: LVIIE=0 */
LVISR &= (unsigned char)~0x40;
/* ### Init_RTC init code */
/* RTCCR1: ALMIE=0,CHRIE=0,DAYIE=0,HRIE=0,MINIE=0,SECIE=1,TB1IE=0,TB2IE=0 */
RTCCR1 = 0x04;
/* RTCCR2: CHRCLR=0,CHRE=0,RTCE=0,XTL2=0,XTL1=0,XTL0=0 */
RTCCR2 = 0x00;
/* ALHR: AH4=0,AH3=0,AH2=0,AH1=0,AH0=0 */
ALHR = 0x00;
/* ALMR: AM5=0,AM4=0,AM3=0,AM2=0,AM1=0,AM0=0 */
ALMR = 0x00;
/* SECR: SEC5=0,SEC4=0,SEC3=0,SEC2=0,SEC1=0,SEC0=0 */
SECR = 0x00;
/* MINR: MIN5=0,MIN4=0,MIN3=0,MIN2=0,MIN1=0,MIN0=0 */
MINR = 0x00;
/* HRR: HR4=0,HR3=0,HR2=0,HR1=0,HR0=0 */
HRR = 0x00;
/* DAYR: DAY4=0,DAY3=0,DAY2=0,DAY1=0,DAY0=1 */
DAYR = 0x01;
/* MTHR: MTH3=0,MTH2=0,MTH1=0,MTH0=1 */
MTHR = 0x01;
/* YRR: YR7=0,YR6=0,YR5=0,YR4=0,YR3=0,YR2=0,YR1=0,YR0=0 */
YRR = 0x00;
/* DOWR: DOW2=0,DOW1=0,DOW0=0 */
DOWR = 0x00;
/* ### */
asm CLI; /* Enable interrupts */
} /*MCU_init*/
我的main函数如下:
#include <hidef.h> /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */

#define LED PTB_PTB3


void MCU_init(void); /* Device initialization function declaration */

/*
** ===================================================================
** Interrupt handler : isrINT_RTC
**
** Description :
** User interrupt service routine.
** Parameters : None
** Returns : Nothing
** ===================================================================
*/
__interrupt void isrINT_RTC(void)
{
/* Write your interrupt code here ... */

LED^=1;

}
/* end of isrINT_RTC */


void main(void) {

/* Uncomment this function call after using Device Initialization
to use the generated code */
MCU_init();

//EnableInterrupts; /* enable interrupts */

/* include your code here */
DDRB_DDRB3 = 1;
LED = 0; /* Turn Off LED */
RTCCR2 |= 0x10;

for(;;) {
//__RESET_WATCHDOG(); /* feeds the dog */
asm("STOP");
} /* loop forever */
/* please make sure that you never leave this function */
}

[此贴子已经被作者于2006-5-24 18:05:17编辑过]

返回列表