Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Moved] strange 16x2 LCD behaviour ?

Status
Not open for further replies.

DTSFA

Newbie level 5
Joined
Oct 30, 2012
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,344
I am using a 16f877 PIC to drive a 16x2 LCD,

if I run the code to where the lift checks if between floors , all is good, if I run code to end , at the start, I get what looks like a 'y' in the display,
and rest of code seems to output weird characters,


Code:
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D4 at RB0_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D7_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
int i=0;

void main() {

ADCON1 = 0x0F;
TRISB = 0;
PORTB = 0xFF;
TRISC = 1;
PORTC = 0x00;
Lcd_Init();

while(1){

for (i=0;i<3;i++){
if (PORTC.F0==0){
Lcd_Out(1,1,"Door fault");
Lcd_Out(2,1,"Check interlocks");
}
else {
Lcd_Out(1,1,"Door closed");
}
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}

for (i=0;i<3;i++){
if (PORTC.F1==0){
Lcd_Out(1,1,"No up safety");
Lcd_Out(2,1,"Platf./Carriage?");
}
else {
Lcd_Out(1,1,"Safety Edge Ok");
}
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}

for (i=0;i<3;i++){
if (PORTC.F2==1){
Lcd_Out(1,1,"Lift at upper");
Lcd_Out(2,1,"Level");
}
else {
Lcd_Out(1,1,"Checking..");
}
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}


for (i=0;i<3;i++){
if (PORTC.F3==1){
Lcd_Out(1,1,"Lift at lower");
Lcd_Out(2,1,"Level");
}
else {
Lcd_Out(1,1,"Between floors");
}
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}


for (i=0;i<3;i++){
if (PORTC.F4==1){
Lcd_Out(1,1,"Lift going up");
}
else {
Lcd_Out(1,1,"Checking..");
}
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}

for (i=0;i<3;i++){
if (PORTC.F5==1){
Lcd_Out(1,1,"Lift going dn");
}
else {
Lcd_Out(1,1,"Checking..");
}
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}
}
}

is this a timing issue ?

or something else, all advice welcome,

( I am rusty on c code at mo, so please go easy)

code is written, compiled using MikroC Pro

thanks
 

Yes. It is natural with PIC16F and mikroC Compiler. It doesn't have bank switching. I guess you are getting "IRP_bit has to be set manually..." in the messages window of Compiler. You have to manually set and clear IRP_bit wherever strings are handled in your code. A better option is to use CopyConst2Ram() function and declare all your strings as const unsigned char.
 

Yes. It is natural with PIC16F and mikroC Compiler. It doesn't have bank switching. I guess you are getting "IRP_bit has to be set manually..." in the messages window of Compiler. You have to manually set and clear IRP_bit wherever strings are handled in your code. A better option is to use CopyConst2Ram() function and declare all your strings as const unsigned char.


many thanks, pointed me in right direction, spot on, cheers
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top