hello 我在調試的時候出現如下問題 Error: At location FFE8 - Error: Attempt to use invalid or uninitialized memory
Error: Interrupt processing failed.
當取消中斷的時候就不會有這些錯誤,請達人指出如何修正``` 下面是我寫的代碼,初次接觸freescale,還需多努力``` 功能是generate 4路,pwm,並且在TPM1TCNL到達TPM1MODL的時候產生一個中斷 此為試驗程序只做練習用``` ----------------------------- MC9HCS08SH8 CW6.0 ----------------------- #include <hidef.h> /* for EnableInterrupts macro */ #include "derivative.h" /* include peripheral declarations */
//#pragma DATA_SEG default //char duty;
unsigned char tt=0;
/*************************************************/ /*OSC_CSH*/ /*************************************************/
void OSC_CSH() { ICSC1=0b01000111; ICSSC&=0x01; //ISC2&ICSTRM should be ignored SRS=0x82; //SBDFR,SOPT1,2 SPMSC1,2 could be ignored
} /*************************************************/ /*IO_CSH*/ /*************************************************/ void IO_CSH(void) { PTADD&=0b00111111; PTADD|=0b00111111; PTBDD=0xFF; //SET ALL AS OUTPUT } /*************************************************/ /*PWM_CSH*/ /*************************************************/ void PWM_CSH() { TPM1SC=0b01001011; TPM2SC=0b00001011; // 1/8 TPM1MODH=0x00; TPM2MODH=0x00; TPM1MODL=0x20; TPM2MODL=0x20; TPM1C0SC=0b00101000; TPM1C1SC=0b00101100; TPM2C0SC=0b00101000; TPM2C1SC=0b00101100; TPM1C0VH=0x00; TPM1C1VH=0x00; TPM2C0VH=0x00; TPM2C1VH=0x00; TPM1C0VL=0x10; TPM1C1VL=0x10; TPM2C0VL=0x10; TPM2C1VL=0x10; } /*************************************************/ /*pwm_interrupt*/ /*************************************************/ interrupt 20 void b(void) { //TPM1SC; TPM1SC_TOF=~TPM1SC_TOF; tt=TPM1C1VL; if (TPM1C1VL<0x20) tt++; else tt--; TPM1C1VL=tt; } /*************************************************/ /*pwm_interrupt*/ /*************************************************/ void main(void) {
EnableInterrupts /* enable interrupts */ /* include your code here */ // duty = 20; OSC_CSH(); IO_CSH(); PWM_CSH(); PTAD=0b00000101; PTAD&=0b00000011; for(;;) { __RESET_WATCHDOG(); /* feeds the dog */ } /* loop forever */ /* please make sure that you never leave main */ }
|