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;
}
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.
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!
-----------------------------------------------------------------------------------------------------------------------