Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD Output with PIC18F problems

Status
Not open for further replies.

Wakestrap

New Member
Hello, I'm having some issues with an LCD Display It initializes fine and writes the first output to the screen no problems but then when it enters the FOR loop it won't output anymore (LCD Cursor just blinks).... Until I Kill the power completely, then turn it back on. Resetting the PIC doesn't seem to do it. But for whatever reason a full power cycle seems to work. I'm wondering if its a timing issue. Here's the code. (mikroC)
void main()
{
char *text;
int deg, j;
TRISB = 0xFF;
TRISD = 0;

//ADCON1 = 0x80;



LCD_Init(&PORTD);
LCD_CMD(LCD_Clear);
LCD_Out(1, 1, "Encoder Reading Test");
delay_ms(5);
LCD_Cmd(LCD_Clear);
//LCD_Cmd(LCD_CURSOR_OFF);

for(;;)
{
deg = PORTB;
InttoStr(deg, text);
LCD_Out(1, 1, text);

}
}

Thanks for the help!!
 
Hello, I'm having some issues with an LCD Display It initializes fine and writes the first output to the screen no problems but then when it enters the FOR loop it won't output anymore (LCD Cursor just blinks).... Until I Kill the power completely, then turn it back on. Resetting the PIC doesn't seem to do it. But for whatever reason a full power cycle seems to work. I'm wondering if its a timing issue. Here's the code. (mikroC)
void main()
{
char *text;
int deg, j;
TRISB = 0xFF;
TRISD = 0;

//ADCON1 = 0x80;



LCD_Init(&PORTD);
LCD_CMD(LCD_Clear);
LCD_Out(1, 1, "Encoder Reading Test");
delay_ms(5);
LCD_Cmd(LCD_Clear);
//LCD_Cmd(LCD_CURSOR_OFF);

for(;;)
{
deg = PORTB;
InttoStr(deg, text);
LCD_Out(1, 1, text);

}
}

Thanks for the help!!


I don't know anything about MikroC, as I use Proton PicBasic Pro, but here is the config I used on a 18F2431 based barometric altimeter.. This should help you get the correct fuses and config bits set.

Code:
Device = 18F2431
XTAL=8
OSCCON = %01110000   ' Internal 8 MHz osc

'THIS CONFIG IS FOR THE INTERNAL 8 MHZ OSCILLATOR, AND MCLRE OFF
@ CONFIG_REQ 
@ __CONFIG CONFIG1H, OSC_IRCIO_1 & FCMEN_OFF_1 & IESO_OFF_1
@ __CONFIG CONFIG2L, BORV_27_2 & BOREN_ON_2 & PWRTEN_ON_2 
@ __CONFIG CONFIG2H, WDTEN_ON_2 & WDPS_32_2 
@ __CONFIG CONFIG3L, T1OSCMX_ON_3 & HPOL_HIGH_3 & PWMPIN_OFF_3
@ __CONFIG CONFIG3H, MCLRE_OFF_3 
@ __CONFIG CONFIG4L, DEBUG_OFF_4 & LVP_OFF_4 & STVREN_ON_4 
@ __CONFIG CONFIG5H, CPB_OFF_5 & CPD_OFF_5 
@ __CONFIG CONFIG5L, CP0_OFF_5 & CP1_OFF_5 & CP2_OFF_5 & CP3_OFF_5
@ __CONFIG CONFIG6H, WRTC_OFF_6 & WRTB_OFF_6 & WRTD_OFF_6 
@ __CONFIG CONFIG6L, WRT0_OFF_6 & WRT1_OFF_6 & WRT2_OFF_6 & WRT3_OFF_6
@ __CONFIG CONFIG7H, EBTRB_OFF_7 
@ __CONFIG CONFIG7L, EBTR0_OFF_7 & EBTR1_OFF_7 & EBTR2_OFF_7 & EBTR3_OFF_7
 
It seems that it IS a config problem but the config settings you provided didn't fix it. Still getting a blank screen once it enters the loop. Any specific fuse settings I should try playing with?
 
It seems that it IS a config problem but the config settings you provided didn't fix it. Still getting a blank screen once it enters the loop. Any specific fuse settings I should try playing with?

Here is my port config using an LCD display.. Again in Proton Picbasic pro, but shouldn't cause any difficulties in deciphering...

Code:
'this bit sets up LCD on PORTB
'Don't forget to connect LCD R/W pin to ground!!
 Declare LCD_TYPE 0
 Declare LCD_INTERFACE 4
 Declare LCD_LINES 2
 Declare LCD_DTPIN PORTB.4
 Declare LCD_RSPIN PORTB.3
 Declare LCD_ENPIN PORTB.2
 Declare LCD_COMMANDUS 3000
 Declare LCD_DATAUS 100
 
Status
Not open for further replies.

Latest threads

Back
Top