ILLEGAL_BP when running my program (mc9s12dp512)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

ILLEGAL_BP when running my program (mc9s12dp512)

1,314 次查看
ibtisbr
Contributor II

Hello , 

 

I'm working toward a project and i want to display some data into a 16x2 LCD using mc9s12dp512 but when runing the program below i get illegal_bp as shown in the attached picture , any idea how i can solve it ? 

#include <hidef.h> /* common defines and macros */
#include "derivative.h" /* derivative-specific definitions */
#include "c:\Program Files (x86)\Freescale\CWS12v5.2\lib\hc12c\include\mc9s12dp512.h"
#define data_port PORTA;


#define rs PORTA_BIT0;
#define rw PORTB_BIT1 ;
#define en PORTB_BIT2 ; // pulse count





void delay_ms(unsigned int msec) {
int i ;
{
while (msec != 0)
{
for (i=5; i >0;i--){};
break;
}

}

}
void lcd_cmd(unsigned char dat)
{

dat =PORTA & 0xFF;
PORTB=PORTB & 0xF1 ;// CLEARS rs=0
PORTB=PORTB & 0xF2;//rw 0;
PORTB=PORTB | 0xFB;//en 1 sets the bit 2 of PORTB to 1 ;
delay_ms(1);
PORTB=PORTB & 0xF4;

}

void lcd_data(unsigned char dat) // Function to send data to LCD
{

dat = PORTA & 0xFF;
PORTB=PORTB | 0xFE; // Rs=1
PORTB=PORTB & 0xF2; //RW=0
PORTB=PORTB | 0xFB;//EN=1
delay_ms(1);
PORTB=PORTB & 0xF4; //EN=

}

void lcd_string( char *str) // Function to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
delay_ms(1);
}
}
main (){
DDRB =0xFF;
DDRA= 0xFF;


lcd_cmd(0x38);
lcd_cmd(0x0c);
delay_ms(2);
lcd_cmd(0x01);
delay_ms(2);
lcd_cmd(0x80);
delay_ms(2);

lcd_string("Range finder");
return 0;

}

0 项奖励
回复
1 回复

1,031 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hello,

When we meet illegal BP error:

First I need to know the problem is due to software or hardware side. Could you please create a new project with wizard, can you download and run the new project code on the board?

If the problem only happened on your own project(no problem with new project), There is no document on the list of illegal BP, but I will try to explain it in detail to you.

 

There can be many reasons for “ILLEGAL_BP” error message.

  1. unmapped interrupt vectors or non-serviced irq is enabled or incorrect ISR vector number is used. The illegal breakpoint error often happens when the MCU is getting lost and executes dummy code. If this happens whenever you enable your interrupt, check that the interrupt vector has been correctly initialized with the address of the interrupt service routine. If the interrupt vector is left blank (0xFFFF) this could be the cause of the problem.
  2. watchdogs: this might be a COP reset, check that the watchog, if enabled, is being fed correctly. Also please check that the stack is not overflowing.
  3. bad SW approach to RAM, e.g. some buffer overflows, STACK overflow…
  4. code optimization by CW may cause the JMP to non-defined program memory address and PC lost way.

 

Please check your code if it belongs to one of the reasons above.


Have a great day,
Jennie Zhang

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复