mc9s12xdp512 interrupt problems.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mc9s12xdp512 interrupt problems.

1,060 Views
sergioloncan
Contributor I


In this simple code, the loop execute some times no more than 10x,

 

and the debugger shoew the ILLEGAL_BP message.

 

When disable the interrupts, it Works fine.

what its the cause of this problem???

Thanks for your attention.. and sorry if i port in wrong place...

 

#include <hidef.h>
#include "derivative.h"


void main()

    {
         unsigned int i;
        __asm(sei); /* Disable interrupts */
        DDRB = 0xff; /* Make Port B output */
        DDRD = 0x3c; // PORT D OUTPUT 2 3 4 5
        PORTD = 0x3c;//portd leds on 2 3 4 5
        PORTB = 0xff;// portb leds on
        TSCR1 = 0x80; /* Turn on timer */
        TSCR2 = 0x8f; /* Enable timer overflow interrupt, set prescaler */
        TFLG2 = 0x80; /* Clear timer interrupt flag */
        __asm(cli); /* Enable interrupts (clear I bit) */
        while (1)
             {
                for (i=0;i<50000;i++)
                  {
                   _FEED_COP(); /* feeds the dog */
                  }
                
                 PORTB =~PORTB;
                
                                  
            }
     }
void interrupt toi_isr(void)
    {
        PORTD = ~PORTD; /* NOT */
        TFLG2 = 0x80; /* Clear timer interrupt flag */
       
    }

Labels (1)
0 Kudos
Reply
4 Replies

835 Views
iggi
NXP Employee
NXP Employee

Hi Sergio,

Here are some forum answers you may want to read:

Illegal BP at starting the engine (KIT33812ECUEVME)

ILLEGAL_BP

Find attached the interrupt catcher example code. Use the link above for the instructions.

Hope it helps.

0 Kudos
Reply

835 Views
sergioloncan
Contributor I

Thanks for the reply , you solved the problem and worked perfectly.

0 Kudos
Reply

835 Views
sergioloncan
Contributor I

Sorry for the delay.

0 Kudos
Reply

835 Views
kef2
Senior Contributor V

Looks like you forgot to initialize interrupt vectors table. Interrupt vectors can be initialized using one of these ways

- inserting proper interrupt after number after "interrupt" keyword. Like    void interrupt N isr(void)

- using "VECTOR N isr" form in prm file

- initializing vectors table array in *.c file

I won't bother providing examples for each of these. Try using forums search. There must be some examples.

BTW, unless you are using small memory model, you need to allocate your ISR's in nonbanked memory using CODE_SEG pragmas:

#pragma CODE_SEG __NEAR_SEG NON_BANKED

// your ISR comes here

#pragma CODE_SEG DEFAULT

Edward

0 Kudos
Reply