在线时间0 小时
UID2030013
注册时间2013-7-31
NXP金币0
该用户从未签到
新手上路

- 积分
- 46
- 最后登录
- 1970-1-1
|
S08SH32,外接3.6864M晶振,程序如下
void init()
{
// Clock
// ICSC2 should be written before ICSC1
// because it contains an option for choosing an oscillator or external crystal
// by setting/clearing the EREFS bit respectively
ICSC2=0b01111111;
ICSC1=0b10000000;
// waiting for crystal initial
while(ICSSC_IREFST!=0);
while(ICSSC_CLKST!=0b10);
while(ICSSC_OSCINIT!=1);
// SYS
SOPT1=0b11000011; // WDT=1.024 s, Stop Mode Disabled, SDA=PTA2, BKGD=PTA4, RST=PTA5
SOPT2=0b00000001; // COP=1Khz, Normal COP, TPM1CH0=PTC0
SPMSC1=0b0100001; // Disable LVD, Bandgap Enable
SPMSC2=0; // no use
// IRQ
IRQSC=0; // disabled
// Interrupt
// IO
PTADD=0x0C;
PTAD=0xFF;
PTAPE=0xF3;
PTASE=0xFF;
PTADS=0xFF;
PTASC=0;
PTAPS=0;
PTAES=0;
PTBDD=0x0E;
PTBD=0xFF;
PTBPE=0xF1;
PTBSE=0xFF;
PTBDS=0xFF;
PTBSC=0;
PTBPS=0;
PTBES=0;
PTCDD=0x01;
PTCD=0xFF;
PTCPE=0x82;
PTCSE=0xFF;
PTCDS=0xFF;
GNGC=0;
// MTIM
MTIMMOD=0;
MTIMCLK=0x08;
MTIMSC=0x60;
}
void main(void) {
DisableInterrupts;
__RESET_WATCHDOG(); /* feeds the dog */
init();
EnableInterrupts;
for(;;) {
__RESET_WATCHDOG(); /* feeds the dog */
} /* loop forever */
}
interrupt VectorNumber_Vmtim void ISR_of_systick(void)
{
static char c=0;
char j=MTIMSC;
MTIMSC_TOF=0;
if(c)
{
c=0;
LED_HB=0;
}
else
{
c=1;
LED_HB=1;
}
}
3.6864M晶振,1/2 BUS,MTIM 256分频自由运行,每次中端改变口线状态。
每次中断应该是35.55mS。
但是抓波形,时间是71.11mS。
不知道是哪里设置的不对,请高手指点下
|
|