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.

problem with mikroc programing lcd code - can any one help me

Status
Not open for further replies.

eng_msa_8_8

Junior Member level 3
Joined
Jun 11, 2009
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,468
how can i send text to the lcd in the mikroc
i use mikroc pro

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

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections



void main()
{

Lcd_Init();
Lcd_Cmd(_LCD_TURN_ON); // Clear the LCD
//Lcd_Out(1,4,"My Computer");
Lcd_Out_Cp("Here!");
Delay_ms(500);
Lcd_Cmd(_LCD_TURN_OFF); // Clear the LCD

}

- - - Updated - - -

is the problem in the code or in the compiler ?
 

Attachments

  • lcd_code.rar
    18.2 KB · Views: 93

is the problem in the code or in the compiler ?
Code.

LCD library requires that you use LAT registers with PIC18 outputs, like this:

Code:
// LCD module connections
sbit LCD_RS at LATB0_bit;
sbit LCD_EN at LATB1_bit;
sbit LCD_D4 at LATB2_bit;
sbit LCD_D5 at LATB3_bit;
sbit LCD_D6 at LATB4_bit;
sbit LCD_D7 at LATB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections



void main()
{

    Lcd_Init();
    Lcd_Cmd(_LCD_TURN_ON);                   // Clear the LCD ? don't think it does - try (_LCD_CLEAR)
    //Lcd_Out(1,4,"My Computer");
    Lcd_Out_Cp("Here!");
    Delay_ms(500);
    Lcd_Cmd(_LCD_TURN_OFF);                 // Clear the LCD

}
 
no output
the screen lights up but no litters

plz try to compile it and send hex file to try it

- - - Updated - - -

i use that code

Code:
// LCD module connections
sbit LCD_RS at LATB0_bit;
sbit LCD_EN at LATB1_bit;
sbit LCD_D4 at LATB2_bit;
sbit LCD_D5 at LATB3_bit;
sbit LCD_D6 at LATB4_bit;
sbit LCD_D7 at LATB5_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
// End LCD module connections



void main()
{

    Lcd_Init();
    Lcd_Cmd(_LCD_TURN_ON);                   // Clear the LCD ? don't think it does - try (_LCD_CLEAR)
    Lcd_Cmd(_LCD_CLEAR);
    //Lcd_Out(1,4,"My Computer");
    Lcd_Out_Cp("Here!");
    Delay_ms(500);
    Lcd_Cmd(_LCD_TURN_OFF);                 // Clear the LCD

}
 

Full project attached. Works for me, latest compiler version, real hardware. 8MHz crystal with 2x22pF caps.

500mS is not very long though, you need to watch the display very carefully or you will miss it.
 

Attachments

  • junk.rar
    16.9 KB · Views: 87

also ur hex file didnt work in my proteus

do u saw my circuit ?
 

do u saw my circuit ?
Ah... I see what you mean....

PIC18F452 requires an external clock circuit of some kind. No wonder that it does not work. Your circuit is no good.

Read the PIC datasheet to find out what kind of clock circuit is needed.
 

the clock is programed in the pic ship window
i selected it as 4Mhz

when i do another codes for led as example it works without external clock


so where is the problem ?
 

the clock is programed in the pic ship window
i selected it as 4Mhz

when i do another codes for led as example it works without external clock


so where is the problem ?
You need to connect R/W pin of both LCD displays to 0 Volts
 

here is some errors
proteus alert me


and ther is another project it works without external clock

- - - Updated - - -

i also in the picture i conected w/r to gnd
 

Attachments

  • 21-10-2012 02-07-07.jpg
    21-10-2012 02-07-07.jpg
    275.1 KB · Views: 110
  • shifting_led$$.rar
    50.1 KB · Views: 86

i think you must set initial value of inputs & outputs zeroes .
 

Here is a version built for 4MHz clock and without turning off the display.

Works on real hardware, but no idea whether it will work with Proteus.

EDIT: ... just noticed .... your original circuit diagram would normally have MCLR connected to a 10K resistor, with the other side of the resistor connected to +5V.
Also LCD2 should have Vee connected to ground, not to +5V, though Proteus probably would not care.
 

Attachments

  • junk.rar
    17.1 KB · Views: 97
Last edited:

HOW ?
plz explain more

- - - Updated - - -

Here is a version built for 4MHz clock and without turning off the display.

Works on real hardware, but no idea whether it will work with Proteus.

EDIT: ... just noticed .... your original circuit diagram would normally have MCLR connected to a 10K resistor, with the other side of the resistor connected to +5V.
Also LCD2 should have Vee connected to ground, not to +5V, though Proteus probably would not care.
what is the meaning of
"hd44780 controller received data whilst busy"
 

Before LCD_init(); command add these lines.

Code:
TRISB = 0x00;
PORTB = 0x00;

and remove this line

Code:
Lcd_Cmd(_LCD_TURN_OFF); // Clear the LCD
otherwise the text will be displayed and then the lcd will turn off. It will happen so fast that you will only see blank lcd.

In Proteus some LCDs are considered HD44780 compatible and hence programmed as HD44780 based LCD.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top