Hi,
I am using CDM16216b LCD to interface with 16f72.I am trying to display characters on lcd,but i didnt get anything on LCD.
Please kindly reply me,where i am going wrong.
Code:list p=16f72 ;PIC16f72 is the target processor INCLUDE "P16f72.INC" ;------------------------------------------------------------------------------------ ; PORTA control bits __CONFIG _PWRTE_ON & _XT_OSC & _WDT_OFF ; configuration switches #DEFINE LCD_RS PORTA, 0 ; RA0 is RS line of LCD #DEFINE LCD_E PORTA, 1 ; RA1 is E line of LCD ; RC0-RC3 are D4-D7 of LCD Temp equ 0x20 delay1 equ 0x21 org 0x00 goto start ;------------------------------------------------------------------------------------ start bsf STATUS, RP0 ; Bank1 errorlevel 1,-302 ; Don't warn me about bank 1 movlw b'00000000' ; Defining input and output pins movwf TRISA ; Writing to TRISA register movlw b'00000000' ; Defining input and output pins movwf TRISB ; Writing to TRISB register 1-input,0-output movlw b'00000000' movwf TRISC movlw b'10000110' ; TMR0,prescaler-128 movwf OPTION_REG movlw 0x07 movwf ADCON1 bcf STATUS, RP0 ; Bank0 clrf PORTA ; potra,portb initially set to low clrf PORTB clrf PORTC call lcd_init bsf PORTA,5 ; Buzzer call delay_0.5s bcf PORTA,5 call disp_main movlw 0xC1 call disp_cmd btfsc PORTB,4 ;UPS RDY call disp_ups lcd_init movlw 0x28 ; 4 bit, 2 Line, 5x7 font call disp_cmd call delay ; movlw 0x10 ; display shift off ; call disp_cmd ; call delay movlw 0x0E ; increment cursor call disp_cmd call delay movlw 0x01 ; Clear the Display RAM call disp_cmd call delay ; Note, Can take up to 4.1 msecs movlw 0x06 ; move the cursor to begining call disp_cmd call delay ; movlw 0x0C ; display on cursor off ; call disp_cmd ; call delay return delay movlw d'236' ;2.5ms delay movwf TMR0 loop1 btfss INTCON,2 goto loop1 clrf INTCON ; if overflow occur,clear INTCON return d ;------------------------------------------------------------------------------------ ;Display command for 4 bit LCD disp_cmd ; Send the Instruction to the LCD movwf Temp ; Save the Temporary Value swapf Temp, w ; Send the High Nybble bcf LCD_RS ; RS = 0 call nibbleout movf Temp, w ; Send the Low Nybble bcf LCD_RS call nibbleout return ;------------------------------------------------------------------------------------ ;sending ASCII character to LCD disp_write ; addlw '0' ; Send nbr as ASCII character ; Send the Character to the LCD movwf Temp ; Save the Temporary Value swapf Temp, w ; the High Nybble bsf LCD_RS ; RS = 1 call nibbleout movf Temp, w ; Send the Low Nybble bsf LCD_RS call nibbleout return ;------------------------------------------------------------------------------------ ;sending lower and upper nibble nibbleout ; Send a nibble to the LCD movwf PORTC bsf LCD_E call delay bcf LCD_E nop nop return disp_main movlw 'M' ; output 'MAIN' call disp_write movlw 'A' call disp_write movlw 'I' call disp_write movlw 'N' call disp_write movlw ' ' call disp_write movlw 'N' call disp_write movlw 'O' call disp_write movlw 'R' call disp_write return end




Bookmarks