Illegal BP with interrupts using DEMO9S12XEP100

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Illegal BP with interrupts using DEMO9S12XEP100

ソリューションへジャンプ
1,460件の閲覧回数
omegaouter
Contributor I

I have had a really bad time trying to find a way to enable interrupts using my demo board. I have been reading in the forum and added pragmas, interrupt vectors and a lot of code. However that doesnt work. 

 

I think im missing something really easy, but its my first time with Freescale. Any help or tip will be a lot of help.

 

Its a demo code to blink the onboard leds. Im sure the toggling code works, but have no idea how to trigger the interrupt or solve the Ilegal BP problem.

 

#include <hidef.h>      /* common defines and macros */#include "mc9s12xep100.h"      /* derivative-specific definitions */#pragma LINK_INFO DERIVATIVE "mc9s12xep100"// Unsecured status flashconst unsigned char flash_security  @0xFF0F = 0xFE;volatile unsigned int x;volatile Bool manuel;void TimerInit(void);/* Start interrupts */  #pragma CODE_SEG __NEAR_SEG NON_BANKED__interrupt 0xEE void TimerOverflow_ISR(void){            TIM_TFLG1 = 0x01;            PORTA = 0x0F;            manuel ^= 1;             TIM_TC0 = TIM_TCNT + 0x0FFF;}#pragma CODE_SEG DEFAULT/* End interrupts */void TimerInit(void){    // setup Timer System Control Registers    TIM_TSCR1  = 0x80; // TSCR1 - Enable normal timer    TIM_TSCR2  = 0x00; // TSCR2 - 0x80 Timer Interrupt Enable    TIM_TSCR2 |= 0x07; // TSCR2 - 0x07 128 Prescaler        TIM_PACTL  = 0x00; // Setup Timer Preset  }void PeriphInit(void){    DDRA  = 0x0F; // Configure A[3..0] as outputs     PORTA = 0x00; // Output 0}void main(void) {    manuel = 0;            PeriphInit();    TimerInit();        TIM_TIOS = 0x01;    TIM_TIE  = 0x01;    TIM_TC0  = TIM_TCNT + 50;         EnableInterrupts;        for(;;) {                if (manuel){               PORTA = 0x0F;        }                else{            PORTA = 0x00;        }            } /* loop forever */  } /* please make sure that you never leave main */
ラベル(1)
0 件の賞賛
返信
1 解決策
791件の閲覧回数
kef
Specialist I

__interrupt 0xEE ...

 

1) Here ^^ the number past interrupt keyword is not the lower address of interrupt vector, but the number counting down from top vector at 0xFFFF. For reset vector at 0xFFFF you write 0, for clock monitor vector - 1, and so on. 85 is TIM channel 0.

2) TIM and ECT are different timers with different vectors. 0xEE is lower part of ECT channel 0 vector. TIM channel 0 vector is at 0xFF54.

3) I guess it may be not specified in any document, hope there is some application note, but instead of numbers here you should use defines from derivative header file. In MC9S12XEP100.H you may find defines like

 

#define Vtimch0                         0xFF54U

 

and

 

#define VectorNumber_Vtimch0            85U

 

Using these defines instead of magic figures, later it will be much more readable and easier to you to change timer channel or interrupt number without looking into datasheet. So please do

 

interrupt VectorNumber_Vtimch0      void TimerOverflow_ISR(void){ ...

  

4. Pragmas in your code are used correctly.

 

 

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
792件の閲覧回数
kef
Specialist I

__interrupt 0xEE ...

 

1) Here ^^ the number past interrupt keyword is not the lower address of interrupt vector, but the number counting down from top vector at 0xFFFF. For reset vector at 0xFFFF you write 0, for clock monitor vector - 1, and so on. 85 is TIM channel 0.

2) TIM and ECT are different timers with different vectors. 0xEE is lower part of ECT channel 0 vector. TIM channel 0 vector is at 0xFF54.

3) I guess it may be not specified in any document, hope there is some application note, but instead of numbers here you should use defines from derivative header file. In MC9S12XEP100.H you may find defines like

 

#define Vtimch0                         0xFF54U

 

and

 

#define VectorNumber_Vtimch0            85U

 

Using these defines instead of magic figures, later it will be much more readable and easier to you to change timer channel or interrupt number without looking into datasheet. So please do

 

interrupt VectorNumber_Vtimch0      void TimerOverflow_ISR(void){ ...

  

4. Pragmas in your code are used correctly.

 

 

0 件の賞賛
返信
791件の閲覧回数
omegaouter
Contributor I

First of all thanks for the explanation it seems to be a lot easier now.

 

Just looked at the header you mentiones and there is the Vtimch0, but I couldnt find VectorNumber_XXX, do I have to set them up or they should be included ?

 

Thanks in advance =)

 

EDIT :  
The sample project had incomplete header files, using this lines did the trick.

#include <MC9S12XEP100.h> /* derivative-specific definitions */
#pragma LINK_INFO DERIVATIVE "MC9S12XEP100"

and

 

interrupt VectorNumber_Vtimch0      void TimerOverflow_ISR(void){

// Code here =)

}

Now it works as intended! Thank you so much again!

0 件の賞賛
返信
791件の閲覧回数
kef
Specialist I

Hm, maybe you are using older CW version, which has older include files? xxxXEP100.H history log has these lines:

 

**      - 02.03.2007, V2.14 :
**               - Interrupt vector numbers added into .H, see VectorNumber_*

 

 

0 件の賞賛
返信