Ankita Agarwal
Joined: 10 Jun 2009 Posts: 7
|
04 Jul 2009 12:11 jhd161a |
|
|
|
|
I have written this code to interface JHD161A with my PIC18F2550 but LCD is showing nothing...i am attaching this code plz help
#include <p18cxxx.h>
#include<delays.h>
#pragma config PLLDIV = 5 // (20 MHz crystal on PICDEM FS USB board)
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2 // Clock source from 96MHz PLL/2
#pragma config FOSC = HSPLL_HS
#pragma config FCMEN = OFF
#pragma config IESO = OFF
#pragma config PWRT = OFF
#pragma config BOR = ON
#pragma config BORV = 3
#pragma config VREGEN = ON //USB Voltage Regulator
#pragma config WDT = OFF
#pragma config WDTPS = 32768
#pragma config MCLRE = ON
#pragma config LPT1OSC = OFF
#pragma config PBADEN = OFF
#pragma config CCP2MX = ON
#pragma config STVREN = ON
#pragma config LVP = OFF
#pragma config DEBUG = OFF
#pragma config XINST = OFF // Extended Instruction Set
#pragma config CP0 = OFF
#pragma config CP1 = OFF
#pragma config CP2 = OFF
#pragma config CP3 = OFF
#pragma config CPB = OFF
#pragma config CPD = OFF
#pragma config WRT0 = OFF
#pragma config WRT1 = OFF
#pragma config WRT2 = OFF
#pragma config WRT3 = OFF
#pragma config WRTB = OFF // Boot Block Write Protection
#pragma config WRTC = OFF
#pragma config WRTD = OFF
#pragma config EBTR0 = OFF
#pragma config EBTR1 = OFF
#pragma config EBTR2 = OFF
#pragma config EBTR3 = OFF
#pragma config EBTRB = OFF
#define LCD_data PORTB
#define LCD_rs PORTAbits.RA0
#define LCD_rw PORTAbits.RA1
#define LCD_en PORTAbits.RA2
void LCD_busy(void);
void LCD_init(void);
void main(void)
{
ADCON1|=0x0F;
TRISAbits.TRISA0=0;
TRISAbits.TRISA1=0;
TRISAbits.TRISA2=0;
LCD_init();
PORTB = 0x83;
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->l
LCD_en = 0;
LCD_busy();
PORTB = 'A'; //Function set: 1 Line, 8-bit, 5x7 dots
LCD_rs = 1; //Selected data register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->l
LCD_en = 0;
LCD_busy();
while(1)
{
};
}
void LCD_init(void)
{
TRISB=0;
PORTB = 0x30; //Function set: 1 Line, 8-bit, 5x7 dots
LCD_rs = 0; //Selected command register
LCD_rw = 0; //We are writing in data register
LCD_en = 1; //Enable H->L
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
PORTB=0x0E;
LCD_rs = 0;
LCD_rw = 0;
LCD_en = 1;
LCD_en = 0;
LCD_busy();
PORTB = 0x01; //Clear LCD
LCD_rs = 0;
LCD_rw = 0;
LCD_en = 1;
LCD_en = 0;
LCD_busy(); //Wait for LCD to process the command
PORTB = 0x06;
LCD_rs = 0;
LCD_rw = 0;
LCD_en = 1;
LCD_en = 0;
LCD_busy();
}
void LCD_busy(void)
{
Delay10KTCYx ( 240 );
}
But nothing is displayed in LCd where is the problem i cudn't get.
|
|