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.

[SOLVED] Mikroc lcd garbage values are displaying

Status
Not open for further replies.

aswathymohan

Member level 4
Member level 4
Joined
Nov 11, 2012
Messages
68
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Visit site
Activity points
1,727
Hi,

I am using a pic development board (v.3) for lcd interfacing program in Mikroc.This is the code which i have used

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(){
  TRISB = 0x00;                           // Configure PORTB pins as digital
  PORTB = 0x00;
   delay_ms(100);
  Lcd_Init();                             // Initialize Lcd
  delay_ms(1000);
  Lcd_Cmd(_LCD_CLEAR);                    // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);               // Cursor off
  delay_ms(100);

  while(1) {                              // Endless loop
       Lcd_Out(1,1,"hello");   // Write text in first row
  }
}

The LCD I am working with is JHD162A and clock frequency is 16 Mhz.I tested the same in Proteus and got output.But in hardware part,it is showing garbage values,how can settle this problem

I checked all the connections -R/w ,contrast is connected to ground,D0-D3 is left open

Regards
 

What exactly do you mean by garbage values? Can you fully describe or post a picture?
You dont need the loop either by the way.
Posting your full configuration would help as would a circuit if you can.
 

What exactly do you mean by garbage values? Can you fully describe or post a picture?
You dont need the loop either by the way.
Posting your full configuration would help as would a circuit if you can.

this is ma code,what m getting is shown in figure
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
const char part1[] = "some text";
char msg[16]; //declare array

// copy const to ram string
char * CopyConst2Ram(char * dest, const char * src){
  char * d ;
  d = dest;
  for(;*dest++ = *src++;)
    ;
  return d;
}
void main(){
  TRISB = 0x00;                           // Configure PORTB pins as digital
  //PORTB = 0x00;
   //delay_ms(100);
  Lcd_Init();                             // Initialize Lcd
  delay_ms(1000);
  Lcd_Cmd(_LCD_CLEAR);                    // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);               // Cursor off
  delay_ms(100);

  while(1) {                              // Endless loop
      Lcd_Out(1,1,CopyConst2Ram(msg,part1));    // Write text in first row
  }
}
[ATTACH=CONFIG]103850._xfImport[/ATTACH]
 

If you are using PIC18F device then replace all RBx_bit in LCD sbit defines to LATBx_bit. It will better if you zip and post your complete mikroC project files. Go to Project>Edit Project... and select XT for OSC if 4 MHz crystal is used. Enable Power ON Timer. Disable watch Dog Timer. Then Compile code.

Is LCDs D0 to D3 left unconnected? Try connecting them to ground.
 

If you are using PIC18F device then replace all RBx_bit in LCD sbit defines to LATBx_bit. It will better if you zip and post your complete mikroC project files. Go to Project>Edit Project... and select XT for OSC if 4 MHz crystal is used. Enable Power ON Timer. Disable watch Dog Timer. Then Compile code.

Is LCDs D0 to D3 left unconnected? Try connecting them to ground.

lcd d0-d3 is left open

m using pic16f877a and in pic development board the crystal is 16 MHz and i have attached my code

View attachment New folder.zip
 
Last edited:

Test this and reply.

i did wat u said,but it was not getting,hav attached the output i got,

grounded the d0-d3

then edited the project properties

20140403_190741[1].jpg
 

Did you try the code I attached in my previous post? Post the circuit of your dev board. Are you using dev board by NSK electronics?
 

Did you try the code I attached in my previous post? Post the circuit of your dev board. Are you using dev board by NSK electronics?

ya i tried ur code,m nt using nsk electronics board,mine s pic development board (version -3)


20140403_201906[1].jpg
 

Attachments

  • Circuit diagram.pdf
    1.6 MB · Views: 107

hi check this code

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

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;

 sbit LED at RB3_bit;
void main()
 {

     TRISB = 0x00;     // PORTB O/P
     Lcd_Init();                 // Initialize LCD
     Lcd_Cmd(_LCD_CLEAR);        // CLEAR display
     Lcd_Cmd(_LCD_CURSOR_OFF);   // Cursor off

 do {
    LED=!LED;
    Delay_ms(1000);  // Delay 1 Sec
     Lcd_Out(1,1,"! working !");      // Write message1 in 1st row
     }

      while(1);  // Infinite loop
}

connect a led RB3. if your led doesnt blink every 1 second. you are having problem with your reset or oscillator. if your led blinks and dont get data on lcd, change your lcd and check the connections of the lcd. there may be a short circuit. put R/W pin of lcd to ground.

all the best
 

OK _ I was asking for your register setup rather than the running code:
On a PIC you need to configure registers to assign functions to the pins.
By default some pins have analogue functions for example.
Take a look at section 4.12 Example 10 on this page:

I think this may help.
Also double check you have the project settings (as milan said above) correct for the speed you are running at
and the crystal you are using (I often make mistakes there - its easy to get confused).
PS... Also check you are not running a 5V only chip at 3.3v (I did some stress testing a while
back and the display output was similar to yours when this was done)
 
Last edited:

Thanks everyone for supporting me,finally i got the output,the problem is with the oscillator frequency,i changed it to 4 Mhz
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top