Hi, i am testing PR 11, the temperature sensor around. After that, I decided to replace the PIC with PIC16f877a. However, when I test the LCD, it just shows grey block on the first line on the LCD. Can anyone explain why?
Following the tutorial, I reroute the pin address since PIC16f877a has more pins. The rest, LCD subroutine remain the same. SO, it looks like this,
LCD =>PIC
DB0~DB7=> RB1~RB7 (portB)
RS =>RD7
E =>RC7
THerefore, i edit the codes to look like this,
//==================include=================================
#include<pic.h>
//===============configuration==============================
__CONFIG (0x3F32);
//===============define IO port=============================
#define lcd PORTB //RB1-RB7
#define RS RD7
#define E RC7
//==============FUNCTION PTOTOTYPE=========================
void e_pulse(void);
void delay(unsigned short i);
void send_char(unsigned char data);
void send_config(unsigned char data);
void lcd_goto(unsigned char data);
void lcd_clr(void);
void dis_num(unsigned long data);
void increment(unsigned long data);
void read_adc(void);
unsigned short read_temp(void);
//====================MAIN================================
unsigned short result;
unsigned short temp,tempA;tempB
void main(void)
{
ADRESH=0; //clear A/D result
ADRESL=0; //clear A/D result
//setting ADCON1 Register
ADCON1=0b11000101; // A/D result right justified,
// configure RA2 and RA5 as digital I/O
TRISA=0b11011011; //configure PORTA I/O direction
TRISB=0b00000000; //configure PORTB as output
TRISC=0b00000000; //configure PORTC as output
TRISD=0b00000000; //configure PORTD as output
TRISE=0b00000000; //set portE as output
PORTA=0;
PORTB=0;
PORTC=0;
PORTD=0;
while(1)
{
send_config(0b00000001); //clear display at lcd
send_config(0b00000010); //Lcd Return to home
send_config(0b00000110); //entry mode-cursor increase 1
send_config(0b00001100); //diplay on, cursor off and cursor blink off
send_config(0b00111000); //function set
lcd_goto(0); //cursor start from beginning
//display character on LCD
send_char(' ');
send_char('T');
send_char('E');
send_char('M');
send_char('P');
send_char('.');
send_char('=');
.........................................................
I check the datasheet and it state that port B has a weak pull up, do i need to add extra code to disable it? The cades are the same, but I don't know why the LCD can't show anything.
Thanks.