Problem with LCD EasyPIC v7

General discussion on mikroC PRO for PIC.
Post Reply
Author
Message
carlitos158
Posts: 1
Joined: 04 Jan 2016 08:16

Problem with LCD EasyPIC v7

#1 Post by carlitos158 » 04 Jan 2016 08:40

Hello,


I have a problem with the LCD display . I use the official lcd with the peak in the box provided ( PIC18F45K22 ) . For code that I used in the examples given.


I wanted to know where is my mistake.
A hard configuration error :?:
A programming error :?:
Or the card is not working properly :?:

Code: Select all

/*
 * Project name:
     Lcd_Test (Demonstration of the LCD library routines)
 * Copyright:
     (c) Mikroelektronika, 2011.
 * Revision History:
     20110929:
       - initial release (FJ);
 * Description:
     This code demonstrates how to use LCD 4-bit library. LCD is first
     initialized, then some text is written, then the text is moved.
 * Test configuration:
     MCU:             PIC18F45K22
                      http://ww1.microchip.com/downloads/en/DeviceDoc/41412D.pdf
     Dev.Board:       EasyPIC7 - ac:LCD
                      http://www.mikroe.com/easypic/
     Oscillator:      HS-PLL 32.0000 MHz, 8.0000 MHz Crystal
     Ext. Modules:    Character Lcd 2x16
                      http://www.mikroe.com/store/components/various/
     SW:              mikroC PRO for PIC
                      http://www.mikroe.com/mikroc/pic/
 * NOTES:
     - Turn on Lcd backlight switch SW4.6. (board specific)
*/

// Lcd module connections
#device
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;

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

char txt1[] = "mikroElektronika";    
char txt2[] = "EasyPIC7";
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(){
  ANSELB = 0;                        // Configure PORTB pins as digital
  
  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();
    }
  }
}
Attachments
IMG_20160104_091345[1].jpg
IMG_20160104_091345[1].jpg (977.81 KiB) Viewed 2415 times
IMG_20160104_091745[1].jpg
IMG_20160104_091745[1].jpg (938.56 KiB) Viewed 2415 times

User avatar
uros.cvetinovic
mikroElektronika team
Posts: 803
Joined: 14 Dec 2015 09:24

Re: Problem with LCD EasyPIC v7

#2 Post by uros.cvetinovic » 05 Jan 2016 19:47

Hi,

You should turn off switches SW12, I am sending you picture of the board, so you can see.
In case your project settings are not good, I am sending you my zipped project

Best regards,

Uros Cvetinovic
Attachments
LCDproject.rar
(29.57 KiB) Downloaded 257 times

User avatar
uros.cvetinovic
mikroElektronika team
Posts: 803
Joined: 14 Dec 2015 09:24

Re: Problem with LCD EasyPIC v7

#3 Post by uros.cvetinovic » 05 Jan 2016 19:48

And the picture:
Attachments
lcd.jpg
lcd.jpg (3.49 MiB) Viewed 2374 times

valentinc
Posts: 2
Joined: 27 May 2023 11:08

Re: Problem with LCD EasyPIC v7

#4 Post by valentinc » 27 May 2023 12:06

I have this exact problem on an EasyPIC v7a. The board itself is working with pretty much everything else (GLCD, 7 segment, LEDs on the ports, various mikroBUS boards) and is configured correctly.
However I cannot seem to be able to make the 2 x 16 LCD to display anything. I'm using the LCD sold by mikroe (with HD44780 controller), stating this for reference although any HD44780 5V LCD should work.

Probing with the oscilloscope reveals the microcontroller just doesn't output anything on PORTB (which is the one connected to the 2 x 16 LCD).
If I modify the example code and comment out everything and just want to turn on some LEDs on PORTB, again it doesn't output anything.
I'm new to mikroC so it's not really clear what is wrong here, but seems to be related to how the compiler is configured as other programs work fine.

An interesting fact is if I choose "Release" instead of "ICD Debug" in the project settings the LCD initializes but still doesn't display anything.
If I compile with "ICD Debug" the LCD doesn't get initialized at all (top row fully on).

What am I doing wrong here ?

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: Problem with LCD EasyPIC v7

#5 Post by IvanJeremic » 30 May 2023 07:56

Hi,

Can you tell me what MCu you are using, and can you send me a detailed picture of your board?

Regards,

Ivan.

valentinc
Posts: 2
Joined: 27 May 2023 11:08

Re: Problem with LCD EasyPIC v7

#6 Post by valentinc » 30 May 2023 10:53

I am using the PIC18F45K22, which is the one that should work with the example program provided in mikroC according to commentaries in the beginning.
Using the 8Mhz cyrstal that came with the board and configured the MCU clock in Project Settings to be 8Mhz.

Just realised this is the actual problem, as MCU clock is 32Mhz due to the internal PLL. Reading the commentaries in the beginning more carefully made me realise what the mistake is.
Also realised the ICD Debug does not work as it wants the mikroICD debugger which this newer board does not have. It has CodeGrip instead.

Thanks for the response anyway, I am posting this for reference as seems other people had this issue as well.

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: Problem with LCD EasyPIC v7

#7 Post by IvanJeremic » 07 Jun 2023 09:57

Hi,

I am glad you managed to find the solution.

And thank you for writing the solution to your problem so others with a similar issue can see it.

Regards,

Ivan.

Post Reply

Return to “mikroC PRO for PIC General”