Reputation: 29
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:
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