Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;*************************************************************************************************
- ;** **
- ;** Header Information **
- ;** **
- ;*************************************************************************************************
- list p=16F877A, r=dec, w=-302
- include <P16F877A.INC>
- __config _WRT_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _HS_OSC
- ;Processor is 16F877A
- ;Default radix is decimal unless otherwise noted
- ;Suppress assembler bank select messages
- ;Program Code Protection Off (CP1/CP0)
- ;Data Code Protection Off (CPD)
- ;DEBUG OFf (DEBUG)
- ;Program ROM Write Enable Off (WRT)
- ;Low Voltage Programming Off (LVP)
- ;Brown Out Detection Off (BODEN)
- ;Power Up Timer On (PWRTE)
- ;Watchdog Timer Off (WDT)
- ;High Speed Crystal Oscillator (HS)
- ;Fosc = 20MHz
- ;*************************************************************************************************
- ;** **
- ;** Variable Definitions **
- ;** **
- ;*************************************************************************************************
- cblock 0x70
- TABLECOUNT ;used in looping routines
- COUNT1 ;used in delay routine
- COUNT2 ;used in delay routine
- COUNT3 ;used in delay routine
- TMP1 ;temporary storage
- TMP2
- TEMPLCD1 ;temp store for 4 bit mode
- TEMPLCD2
- endc
- ;*************************************************************************************************
- ;** **
- ;** LCD Handshake Lines **
- ;** **
- ;*************************************************************************************************
- LCD_DATAPORT EQU PORTD
- LCD_DATATRIS EQU TRISD
- LCD_FNPORT EQU PORTE
- LCD_FNTRIS EQU TRISE
- #define LCD_RS PORTE,0
- #define LCD_RW PORTE,1
- #define LCD_E PORTE,2
- ;*************************************************************************************************
- ;** **
- ;** Initialization Routine **
- ;** **
- ;*************************************************************************************************
- org 0x000 ;reset vector
- goto START
- START clrf PORTA ;init all ports
- clrf PORTB
- clrf PORTC
- clrf PORTD
- clrf PORTE
- clrf count
- banksel ADCON1 ;bank 1
- movlw b'00000110' ;AN0-AN7 digital I/O
- movwf ADCON1
- movlw b'00000000' ;all ports output
- movwf TRISD
- movwf TRISE
- banksel 0x00 ;bank 0
- call LCD_Init ;setup LCD
- goto $ ;done
- ;*************************************************************************************************
- ;** **
- ;** Subroutines **
- ;** **
- ;*************************************************************************************************
- ;Delays
- Delay125uS movlw 113
- movwf COUNT1
- decfsz COUNT1,F
- goto $-1
- return
- Delay5mS movlw 0xFF ;init delay counters 1 and 2
- movwf COUNT1
- movlw 0x20
- movwf COUNT2
- decfsz COUNT1,F ;decrement COUNT1 until COUNT1 = 0
- goto $-1
- decfsz COUNT2,F ;decrement COUNT1 again until COUNT2 = 0
- goto $-3
- return
- Delay movwf COUNT3
- call Delay40mS
- decfsz COUNT3,F
- goto $-2
- return
- ;*************************************************************************************************
- ;LCD Initialization
- LCD_Init bcf LCD_E ;e line low
- bcf LCD_RS ;RS line low, set up for control
- call Delay125uS ;delay 125uS
- movlw 0x38 ;8-bit, 5x7
- movwf LCD_DATAPORT ;0011 1000
- call Pulse ;pulse and delay
- movlw 0x0F ;display on, cursor blinking]
- movwf LCD_DATAPORT ;0000 1111
- call Pulse
- movlw 0x01 ;clear display
- movwf LCD_DATAPORT ;0000 0001
- call Pulse
- call Delay5mS ;delay 5mS after init
- return
- ;*************************************************************************************************
- end ;end of file
Add Comment
Please, Sign In to add comment