t3nsa
t3nsa

Reputation: 850

Proteus show characters on LCD ( LM015L )

I've been trying to show some characters on LCD ( LM015L ) but I wasn't able to do it.

I've written the following code in c:

// LCD module connections
sbit LCD_RS at LATD0_bit;
sbit LCD_EN at LATD1_bit;
sbit LCD_D4 at LATD2_bit;
sbit LCD_D5 at LATD3_bit;
sbit LCD_D6 at LATD4_bit;
sbit LCD_D7 at LATD5_bit;

sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISD2_bit;
sbit LCD_D5_Direction at TRISD3_bit;
sbit LCD_D6_Direction at TRISD4_bit;
sbit LCD_D7_Direction at TRISD5_bit;
// End LCD module connections


void main() {

 Lcd_Init(); // Initialize LCD
 Lcd_Cmd(_LCD_CLEAR); // Clear display
 Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

 Lcd_Out(1, 1, "microcontrollers"); // Display "StudentCompanion"
 Lcd_Out(2, 1, "lab.com"); // Display "Thermometer"

}

And I've designed the following scheme in proteus

enter image description here

After I run the simulation the LCD turns on and nothing is shown on it

Upvotes: 0

Views: 319

Answers (1)

Kozmotronik
Kozmotronik

Reputation: 2520

Since PORTD pins are multiplexed with analog hardware you should manually disable the analog inputs. This is what is missing in your code. Note that every time a reset occurs on PIC, the default input functions of PORTS are the analog inputs.

/ LCD module connections
sbit LCD_RS at LATD0_bit;
sbit LCD_EN at LATD1_bit;
sbit LCD_D4 at LATD2_bit;
sbit LCD_D5 at LATD3_bit;
sbit LCD_D6 at LATD4_bit;
sbit LCD_D7 at LATD5_bit;

sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISD2_bit;
sbit LCD_D5_Direction at TRISD3_bit;
sbit LCD_D6_Direction at TRISD4_bit;
sbit LCD_D7_Direction at TRISD5_bit;
// End LCD module connections


void main() {
 // The library only configures the direction of pins but not the analog functions. So you must do it before initializing the LCD module.
 ANSELD = 0; // Disable analog functions on PORTD

 Lcd_Init(); // Initialize LCD
 Lcd_Cmd(_LCD_CLEAR); // Clear display
 Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

 Lcd_Out(1, 1, "microcontrollers"); // Display "StudentCompanion"
 Lcd_Out(2, 1, "lab.com"); // Display "Thermometer"

}

Upvotes: 0

Related Questions