Problem LCD Pic18F452

General discussion on mikroC.
Post Reply
Author
Message
Fabiano
Posts: 29
Joined: 28 Apr 2010 21:07

Problem LCD Pic18F452

#1 Post by Fabiano » 18 Jan 2011 20:06

I am not able to make the display work.

I copied the example of the compiler and changed the pins for the connection I'm using.


// LCD module connections
sbit LCD_RS at Re2_bit;
sbit LCD_EN at Re1_bit;
sbit LCD_D4 at Rd4_bit;
sbit LCD_D5 at Rd5_bit;
sbit LCD_D6 at Rd6_bit;
sbit LCD_D7 at Rd7_bit;

sbit LCD_RS_Direction at TRISe2_bit;
sbit LCD_EN_Direction at TRISe1_bit;
sbit LCD_D4_Direction at TRISd4_bit;
sbit LCD_D5_Direction at TRISd5_bit;
sbit LCD_D6_Direction at TRISd6_bit;
sbit LCD_D7_Direction at TRISd7_bit;
// End LCD module connections

char txt1[] = "mikroElektronika";
char txt2[] = "EasyPIC5";
char txt3[] = "Lcd4bit";
char txt4[] = "example";

char i; // Loop variable

void Move_Delay() { // Function used for text moving
Delay_ms(500); // You can change the moving speed here
}

void main(){
TRISd = 0;
PORTd = 0xFF;
TRISd = 0xff;

TRISe = 0;
PORTe = 0xFF;
TRISe = 0xff;
ADCON1 = 0x07;
Lcd_Init(); // Initialize LCD

Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,6,txt3); // Write text in first row

Lcd_Out(2,6,txt4); // Write text in second row
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR); // Clear display

Lcd_Out(1,1,txt1); // Write text in first row
Lcd_Out(2,5,txt2); // Write text in second row

Delay_ms(2000);

// Moving text
for(i=0; i<4; i++) { // Move text to the right 4 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}

while(1) { // Endless loop
for(i=0; i<8; i++) { // Move text to the left 7 times
Lcd_Cmd(_LCD_SHIFT_LEFT);
Move_Delay();
}

for(i=0; i<8; i++) { // Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
}
}

0 103 Finished successfully: 18 jan 2011, 16:38:50 Teste_lcd.mcppi

pwdixon
Posts: 1431
Joined: 13 Apr 2005 11:14
Location: UK

Re: Problem LCD Pic18F452

#2 Post by pwdixon » 19 Jan 2011 18:58

This looks like MikroC Pro code, if so try the Pro forum

Post Reply

Return to “mikroC General”