LCD does not boot into PORTS A_E

General discussion on mikroElektronika website & forums.
Post Reply
Author
Message
jacktaylor
Posts: 12
Joined: 28 Aug 2017 23:20

LCD does not boot into PORTS A_E

#1 Post by jacktaylor » 29 Aug 2017 00:07

:cry: :cry: :roll: :roll: Hi friends. I'm trying to initialize the LCD using PORT (a) from RA1 to RA5 plus PORT RE0 (e) using the Mikroc library, but the LCD in this configuration does not boot, in other PORTs like (B), (C), (D) It works normal. My development board is with this hardware configuration, it came with a program recorded on the PIC16F877A that analog input AN0. When you run this program, the LCD will initialize and write on the screen. Do you have any tips to solve this problem? I'm using the PIC16F877A. The code is:

sbit LCD_RS at RA1_bit;
sbit LCD_EN at RA2_bit;
sbit LCD_D4 at RA3_bit;
sbit LCD_D5 at RA4_bit;
sbit LCD_D6 at RA5_bit;
sbit LCD_D7 at RE0_bit;

sbit LCD_RS_Direction at TRISA1_bit;
sbit LCD_EN_Direction at TRISA2_bit;
sbit LCD_D4_Direction at TRISA3_bit;
sbit LCD_D5_Direction at TRISA4_bit;
sbit LCD_D6_Direction at TRISA5_bit;
sbit LCD_D7_Direction at TRISE0_bit;

lcd_Init ();
Lcd_Chr_CP ('F');
Lcd_Chr_CP (' ');
Lcd_Chr_CP ('H');
Lcd_Chr_CP ('O');
Lcd_Chr_CP ('L');
Lcd_Chr_CP ('A');
Lcd_Out_CP ("Work");
Lcd_Out (2,1, "You can");
delay_ms (300);
Lcd_Cmd (_LCD_CLEAR);
Lcd_Cmd (_LCD_CURSOR_OFF);
delay_ms (300);
Lcd_Cmd (_LCD_BLINK_CURSOR_ON);
Lcd_Out_CP ("Estudante");
delay_ms(200);
}

I was able to initialize the LCD with this program, but when sending write nothing appears on the screen, it only initializes with the blinking course. But it still does not write on the LCD.

void main()
{

ADCON0 = 0b00000000;
ADCON1= 0b00001110;
TRISA = 0b00000001;
TRISE = 0x00;
PORTA = 0b00000000; // 1º send
PORTE = 0b00000000; // 1º send
//delay_ms (200);
RA5_bit = 1; // start send
//delay_ms(200);
RA5_bit = 0;
delay_ms(200);
PORTA = 0b00011000; // 2º send
delay_ms (200);
RA5_bit = 1; // start send
//delay_ms(200);
RA5_bit = 0;
delay_ms(200);
PORTA = 0b00011000; // 3º send
delay_ms (200);
RA5_bit = 1; // start send
//delay_ms(200);
RA5_bit = 0;
delay_ms(200);
PORTA = 0b00011000; // 4º send
delay_ms (200);
RA5_bit = 1; // start send
delay_ms(200);
RA5_bit = 0;
//delay_ms(200);
PORTA = 0b00001000; // 5º send
delay_ms (200);
RA5_bit = 1; // start send
//delay_ms(200);
RA5_bit = 0;
delay_ms(200);
PORTA = 0b00001000; // 6º send
delay_ms (200);
RA5_bit = 1; // start send
//delay_ms(200);
RA5_bit = 0;
delay_ms(200);
PORTA = 0b00000010; // 7º envio
delay_ms (200);
RA5_bit = 1; // start send
//delay_ms(200);
RA5_bit = 0;
delay_ms(200);
PORTA = 0b00000000; // 8º send
delay_ms (200);
RA5_bit = 1; // start send
//delay_ms(200);
RA5_bit = 0;
delay_ms(200);
PORTA = 0b00011110; // 9º send
delay_ms (200);
RA5_bit = 1; // start Sent
//delay_ms(200);
RA5_bit = 0;
delay_ms(200);
}
Attachments
without signal To D4, D5, D6, D7 pins Simulation Proteus
without signal To D4, D5, D6, D7 pins Simulation Proteus
LCDnaoInicializado.JPG (131.97 KiB) Viewed 7497 times
Simulation Proteus
Simulation Proteus
LCD_PortsA-E.JPG (120.93 KiB) Viewed 7497 times

User avatar
darko.ilijevski
Posts: 581
Joined: 21 Mar 2017 16:57

Re: LCD does not boot into PORTS A_E

#2 Post by darko.ilijevski » 29 Aug 2017 20:56

Hello,

For this to work on the PORT A, you need a pull up resistor on your RA4 pin. That is because RA4 is open-drain and it can only sink the current, it's unable to set itself high.
One pull up of about 4K7 will solve your issue.

Best regards
BR,
Darko

jacktaylor
Posts: 12
Joined: 28 Aug 2017 23:20

Re: LCD does not boot into PORTS A_E

#3 Post by jacktaylor » 29 Aug 2017 22:17

Hello darko.ilijevski, thanks for your help.

I had already put the 4k7 resistor on the RA4 pin and it did not work either. My development board has a 10K resistor on the RA4 pin and as I mentioned in the topic, when loading the program that was recorded on the PIC16F877A of the board the LCD works normally, however when placing another program created in the MikroC or even in the CCS, the LCD does not Prints the messages on the screen. It has already been tested with 4k7 and 10k resistors and simulated without working on Proteus or on the development board circuit design is attached.
Attachments
LCDnaoInicializado2.JPG
LCDnaoInicializado2.JPG (115.41 KiB) Viewed 7488 times

hexreader
Posts: 1786
Joined: 27 Jun 2010 12:07
Location: England

Re: LCD does not boot into PORTS A_E

#4 Post by hexreader » 29 Aug 2017 22:48

Your schematic does not tie up with your port definitions:

Code: Select all

sbit LCD_RS at RA1_bit;
sbit LCD_EN at RA2_bit;
sbit LCD_D4 at RA3_bit;
sbit LCD_D5 at RA4_bit;
sbit LCD_D6 at RA5_bit;
sbit LCD_D7 at RE0_bit;
EDIT: sorry, ignore me. I seem to have gone blind or daft :(
Last edited by hexreader on 30 Aug 2017 14:29, edited 1 time in total.
Start every day with a smile...... (get it over with) :)

jacktaylor
Posts: 12
Joined: 28 Aug 2017 23:20

Re: LCD does not boot into PORTS A_E

#5 Post by jacktaylor » 30 Aug 2017 05:29

Hello Joined, thanks for your help. But you don't understood my problem..

My didactic board, has the configuration of hardware already mounted

sbit LCD_RS at RA1_bit;
sbit LCD_EN at RA2_bit;
sbit LCD_D4 at RA3_bit;
sbit LCD_D5 at RA4_bit;
sbit LCD_D6 at RA5_bit;
sbit LCD_D7 at RE0_bit;

according to the simulated in Proteus. The LCD works normally with the program that was recorded in PIC16F877A, but it does not boot with any other programs I do and I load the PIC. That is, it works only with the settings of the .hex program originally recorded in the PIC.
See that the LCD initializes and displays data on the screen with the program originally recorded by the card manufacturer.

But don't initialize with my simple program:

sbit LCD_RS at RA1_bit;
sbit LCD_EN at RA2_bit;
sbit LCD_D4 at RA3_bit;
sbit LCD_D5 at RA4_bit;
sbit LCD_D6 at RA5_bit;
sbit LCD_D7 at RE0_bit;

sbit LCD_RS_Direction at TRISA1_bit;
sbit LCD_EN_Direction at TRISA2_bit;
sbit LCD_D4_Direction at TRISA3_bit;
sbit LCD_D5_Direction at TRISA4_bit;
sbit LCD_D6_Direction at TRISA5_bit;
sbit LCD_D7_Direction at TRISE0_bit;

lcd_Init ();
Lcd_Chr_CP ('F');
Lcd_Chr_CP (' ');
Lcd_Chr_CP ('H');
Lcd_Chr_CP ('O');
Lcd_Chr_CP ('L');
Lcd_Chr_CP ('A');
Lcd_Out_CP ("Work");
Lcd_Out (2,1, "You can");
delay_ms (300);
Lcd_Cmd (_LCD_CLEAR);
Lcd_Cmd (_LCD_CURSOR_OFF);
delay_ms (300);
Lcd_Cmd (_LCD_BLINK_CURSOR_ON);
Lcd_Out_CP ("Estudante");
delay_ms(200);
}
Attachments
PUCposGrad.7z
(7.67 KiB) Downloaded 165 times
LCD_PortsA-E_Pot.JPG
LCD_PortsA-E_Pot.JPG (125.03 KiB) Viewed 7486 times

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: LCD does not boot into PORTS A_E

#6 Post by filip » 30 Aug 2017 14:18

Hi,

Have you tried toggling the Lcd pins (PORTA and PORTE.0) to see if they are properly set as digital ?

Regards,
Filip.

User avatar
darko.ilijevski
Posts: 581
Joined: 21 Mar 2017 16:57

Re: LCD does not boot into PORTS A_E

#7 Post by darko.ilijevski » 30 Aug 2017 17:38

Hi,

Try what Filip suggested to verify your pins have good connections, indeed. Also I think that your program does not call the function you have made. You have a main() function where you haven't used the function which would initialize the LCD. Also do not touch TRISA and TRISE, those are taken care of in the library (except the bit for the RA0 which I have set additionally without touching the rest of them)

Try with this code (copy - paste in your compiler)

Code: Select all

sbit LCD_RS at RA1_bit;
sbit LCD_EN at RA2_bit;
sbit LCD_D4 at RA3_bit;
sbit LCD_D5 at RA4_bit;
sbit LCD_D6 at RA5_bit;
sbit LCD_D7 at RE0_bit;

sbit LCD_RS_Direction at TRISA1_bit;
sbit LCD_EN_Direction at TRISA2_bit;
sbit LCD_D4_Direction at TRISA3_bit;
sbit LCD_D5_Direction at TRISA4_bit;
sbit LCD_D6_Direction at TRISA5_bit;
sbit LCD_D7_Direction at TRISE0_bit;

void InitMyLCD()
{
  lcd_Init ();
  delay_ms (300);
  Lcd_Cmd (_LCD_CLEAR);
  Lcd_Cmd (_LCD_CURSOR_OFF);
  delay_ms (300);
  Lcd_Chr_CP ('F');
  Lcd_Chr_CP (' ');
  Lcd_Chr_CP ('H');
  Lcd_Chr_CP ('O');
  Lcd_Chr_CP ('L');
  Lcd_Chr_CP ('A');
  Lcd_Out_CP ("Work");
  Lcd_Out (2,1, "You can");

  Lcd_Cmd (_LCD_BLINK_CURSOR_ON);
  Lcd_Out_CP ("Estudante");
  delay_ms(200);
}

void main()
{
  ADCON1= 0b00001110;
  TRISA0_bit = 0;
  InitMyLCD();
  
  PORTA = 0b00000000; // 1º send
  PORTE = 0b00000000; // 1º send
  //delay_ms (200);
  RA5_bit = 1; // start send
  //delay_ms(200);
  RA5_bit = 0;
  delay_ms(200);
  PORTA = 0b00011000; // 2º send
  delay_ms (200);
  RA5_bit = 1; // start send
  //delay_ms(200);
  RA5_bit = 0;
  delay_ms(200);
  PORTA = 0b00011000; // 3º send
  delay_ms (200);
  RA5_bit = 1; // start send
  //delay_ms(200);
  RA5_bit = 0;
  delay_ms(200);
  PORTA = 0b00011000; // 4º send
  delay_ms (200);
  RA5_bit = 1; // start send
  delay_ms(200);
  RA5_bit = 0;
  //delay_ms(200);
  PORTA = 0b00001000; // 5º send
  delay_ms (200);
  RA5_bit = 1; // start send
  //delay_ms(200);
  RA5_bit = 0;
  delay_ms(200);
  PORTA = 0b00001000; // 6º send
  delay_ms (200);
  RA5_bit = 1; // start send
  //delay_ms(200);
  RA5_bit = 0;
  delay_ms(200);
  PORTA = 0b00000010; // 7º envio
  delay_ms (200);
  RA5_bit = 1; // start send
  //delay_ms(200);
  RA5_bit = 0;
  delay_ms(200);
  PORTA = 0b00000000; // 8º send
  delay_ms (200);
  RA5_bit = 1; // start send
  //delay_ms(200);
  RA5_bit = 0;
  delay_ms(200);
  PORTA = 0b00011110; // 9º send
  delay_ms (200);
  RA5_bit = 1; // start Sent
  //delay_ms(200);
  RA5_bit = 0;
  delay_ms(200);
}
Regards
BR,
Darko

jacktaylor
Posts: 12
Joined: 28 Aug 2017 23:20

Re: LCD does not boot into PORTS A_E

#8 Post by jacktaylor » 30 Aug 2017 18:41

Hello Filip. Yes, I already did this test.

jacktaylor
Posts: 12
Joined: 28 Aug 2017 23:20

Re: LCD does not boot into PORTS A_E

#9 Post by jacktaylor » 30 Aug 2017 19:31

hI darko.ilijevski<<< Thank you for your help. Now the LCD has initialized and written. I already recorded my first program on my didactic plate and it worked. I am very happy for the help of all of you. Thank you!

sbit LCD_RS at RE0_bit;
sbit LCD_EN at RA5_bit;
sbit LCD_D4 at RA4_bit;
sbit LCD_D5 at RA3_bit;
sbit LCD_D6 at RA2_bit;
sbit LCD_D7 at RA1_bit;

sbit LCD_RS_Direction at TRISE0_bit;
sbit LCD_EN_Direction at TRISA5_bit;
sbit LCD_D4_Direction at TRISA4_bit;
sbit LCD_D5_Direction at TRISA3_bit;
sbit LCD_D6_Direction at TRISA2_bit;
sbit LCD_D7_Direction at TRISA1_bit;

sbit LCD_RS at RE0_bit;
sbit LCD_EN at RA5_bit;
sbit LCD_D4 at RA4_bit;
sbit LCD_D5 at RA3_bit;
sbit LCD_D6 at RA2_bit;
sbit LCD_D7 at RA1_bit;

sbit LCD_RS_Direction at TRISE0_bit;
sbit LCD_EN_Direction at TRISA5_bit;
sbit LCD_D4_Direction at TRISA4_bit;
sbit LCD_D5_Direction at TRISA3_bit;
sbit LCD_D6_Direction at TRISA2_bit;
sbit LCD_D7_Direction at TRISA1_bit;

void InitMyLCD()
{
lcd_Init ();
delay_ms (300);
Lcd_Cmd (_LCD_CLEAR);
Lcd_Cmd (_LCD_CURSOR_OFF);
delay_ms (300);
Lcd_Chr_CP ('H');
Lcd_Chr_CP ('I');
Lcd_Chr_CP ('>');
Lcd_Chr_CP ('H');
Lcd_Chr_CP ('O');
Lcd_Chr_CP ('L');
Lcd_Chr_CP ('A');
Lcd_Chr_CP ('>');
Lcd_Out_CP ("Work ");
Lcd_Out (2,1, "You can");

Lcd_Cmd (_LCD_BLINK_CURSOR_ON);
Lcd_Out_CP ("Estudante");
delay_ms(200);
}

void main()
{
ADCON1= 0b00001110;
TRISA0_bit = 0;
InitMyLCD();
}

User avatar
darko.ilijevski
Posts: 581
Joined: 21 Mar 2017 16:57

Re: LCD does not boot into PORTS A_E

#10 Post by darko.ilijevski » 30 Aug 2017 19:43

Great, I am glad we could help you.

Best regards.
BR,
Darko

jacktaylor
Posts: 12
Joined: 28 Aug 2017 23:20

Re: LCD does not boot into PORTS A_E

#11 Post by jacktaylor » 31 Aug 2017 17:45

darko.ilijevski, thank you very much.

I have another question. What would be the same code in the CCS compiler? CCS by default sets PORT_D in library #include <lcd.c>, it is easy to switch to PORT_B inserted in the #define directive use_portb_lcd true.
I made this code that in the attempt to use the PORTs_A, E. used in MikroC programming, but does not initialize the LCD. Where is the error?

#include <16F877a.h>
#device ADC = 10 // 8-bit converter
#fuses hs, nowdt, nolvp
#use delay (clock = 20M)
#define use_porta_lcd true
#define use_porte_lcd true
#include <lcd.c>
#use fast_io (a)
#use fast_io (e)
#byte ADCON1 = 0x9F // register address ADCON1

Void main (void)
{
    SETUP_ADC_PORTS (AN0);
    Set_tris_a (0b00000001); // the first pin Analogic
    Set_tris_e (0x11111110);
    ADCON1 = 0b00001110;
    Init_lcd ();
    Printf (lcd_txt, "PIC and LCD");
    Dealy_ms (3000);

}

Would it be necessary to change something in the library #include <lcd.c> or would it be easier to setup an initialization program for the LCD?

User avatar
darko.ilijevski
Posts: 581
Joined: 21 Mar 2017 16:57

Re: LCD does not boot into PORTS A_E

#12 Post by darko.ilijevski » 04 Sep 2017 20:13

Hi,

I am sorry but I have no idea how their LCD libraries work, it's MicroChip's product. My guess is that you shouldn't touch the PORTs A and E as a whole, try only ORing the bits you need to set for the AD convertor. Try that way, see if it helps...

Code: Select all

TRISA |= 0x01;
Best regards
BR,
Darko

jacktaylor
Posts: 12
Joined: 28 Aug 2017 23:20

Re: LCD does not boot into PORTS A_E

#13 Post by jacktaylor » 05 Sep 2017 16:30

Thank you darko.ilijevski.

User avatar
darko.ilijevski
Posts: 581
Joined: 21 Mar 2017 16:57

Re: LCD does not boot into PORTS A_E

#14 Post by darko.ilijevski » 06 Sep 2017 11:29

Hi,
You are welcome

Regards
BR,
Darko

Post Reply

Return to “Website & Forums General Discussion”