I have an LCD hooked up to the A ports of a PIC16F877a (A0, A1, A2 etc). However, the display doesn't work because PORTA is configured as analog by default.
In an PIC18F46K22 I'd do it using ANSELA = 0x00; but there is no such option in the PIC16F877A. I looked everywhere on the internet and some solutions suggested turning off the ADCON1 and bits, but nothing, ABSOLUTELY nothing works.
I changed the connection pins to PORTD (D0, D1, D2 etc) and it worked just fine. The problem is the analog configuration of PORTA which I can't change no matter what I try.
I am using MikroC for the program and here's my code:
sbit LCD_RS at RA0_bit;
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RA2_bit;
sbit LCD_D5 at RA3_bit;
sbit LCD_D6 at RA4_bit;
sbit LCD_D7 at RA5_bit;
// Pin direction
sbit LCD_RS_Direction at TRISA0_bit;
sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISA2_bit;
sbit LCD_D5_Direction at TRISA3_bit;
sbit LCD_D6_Direction at TRISA4_bit;
sbit LCD_D7_Direction at TRISA5_bit;
void main()
{
ADCON1 = 0x00;
ADCON0 = 0x00;
TRISA = 0x00;
Lcd_Init();
while (1)
{
Lcd_Out(1,1,"Hello");
Lcd_Out(2,1,"World");
}
}
This site is my last hope, I don't even know if there's another human who uses this microcontroller in 2023 :D
EDIT: ANSELH doesn't exist either. Even ChatGPT fails to solve this issue.