AnsweredAssumed Answered

mc9s12xdp512 interrupt problems.

Question asked by Sergio Loncan on Nov 17, 2014
Latest reply on Dec 13, 2014 by Sergio Loncan


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 */
       
    }

Outcomes