user3674628
user3674628

Reputation: 29

Can't get working 16x2 Character LCD with Pic16f877a

i have been recently learning microcontroller and now I am trying to make an LCD program with MPLAB X ide and XC8 but in the hard way using no libraries of XC8 but it is not working at all here are all the details:

  1. Components:
    • LCD LM016L
    • Microcontroller pic16f877a
  2. Pin connections:
    • Register select pin --> pin E0, Read/Write pin --> pin E1, Register Select pin --> pin E2
    • Data lines (8 bits mode) port D.

Now this is the whole code:

#include "config.h"

//port E pin 0 --> RS, pin 1 --> R/W, pin 2 --> En
#define RS TRISE0
#define RW TRISE1
#define EN TRISE2


void blinkEnable(void);
void check_if_busy(void);
void send_a_command(int command);
void send_a_character(int character);


void main(){
    
    blinkEnable();
    __delay_ms(10);
    check_if_busy();
    __delay_ms(10);
    send_a_command(0x01);
    __delay_ms(10);
    send_a_character(0x46);
    
    while(1){
    }
    
}

void blinkEnable(){
    
    TRISEbits.EN = 1;
    __delay_ms(10);
    TRISEbits.EN = 0;
    __delay_ms(10);
    
    
}
void check_if_busy(){
    
    TRISEbits.RS = 0;
    TRISEbits.RW = 1;
    TRISDbits.TRISD7 = 1;
    while(PORTDbits.RD7 == 1){
        
        
    }
    
}
void send_a_command(int command){
    TRISEbits.RW = 0;
    TRISEbits.RS = 0;
    
    PORTD = command;
    
}
void send_a_character(int character){
    TRISEbits.RW = 0;
    TRISEbits.RS = 1;
    
    PORTD = character;
    
}

Upvotes: 1

Views: 1210

Answers (0)

Related Questions