list p=16F88 ; list directive to define processor #include ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF ;***** VARIABLE DEFINITIONS loop EQU 0x20 d1 EQU 0x21 d2 EQU 0x22 ; RS --> RA3 ; R/W --> RA6 ; Enable --> RA4 ; DB0 --> RB0 ; DB1 --> RB1 ; DB2 --> RB2 ; DB3 --> RB3 ; DB4 --> RB4 ; DB5 --> RB5 ; DB6 --> RB6 ; DB7 --> RB7 ; Hintergundbeleuchtung --> RA1 #define RS PORTA, 3 #define RW PORTA, 6 #define LCD_E PORTA, 4 #define LED PORTA, 1 ;********************************************************************** ORG 0x000 ; processor reset vector goto main_1 ; go to beginning of program init clrf PORTA clrf PORTB bsf STATUS, RP0 bcf STATUS, RP1 clrf TRISA ; alle PORTS als Output clrf TRISB clrf OSCTUNE ; Freuq = 4MHz bsf OSCCON, 6 ; Freuq = 4MHz bsf OSCCON, 5 ; Freuq = 4MHz bcf OSCCON, 4 ; Freuq = 4MHz clrf ANSEL ; PORTA als I/O Pins verwenden bcf STATUS, RP0 bcf STATUS, RP1 bsf LED ; LCD Hintergrundbeleuchtung ein return init_LCD movlw d'30' ; 30ms Warteschleife movwf loop call wait bcf RS ; Function Set --> 2-line mode / display on bcf RW movlw b'00111100' movwf PORTB bsf LCD_E nop nop bcf LCD_E movlw d'1' ; 1ms Warteschleife movwf loop call wait bcf RS ; Display ON/OFF Controll --> display on / cursor on / cursor blink on bcf RW movlw b'00001111' movwf PORTB bsf LCD_E nop nop bcf LCD_E movlw d'1' ; 1ms Warteschleife movwf loop call wait bcf RS ; Display clear bcf RW movlw b'00000001' movwf PORTB bsf LCD_E nop nop bcf LCD_E movlw d'2' ; 2ms Warteschleife movwf loop call wait bcf RS ; Entry Mode Set --> increment mode / entire shift on bcf RW movlw b'00000111' movwf PORTB bsf LCD_E nop nop bcf LCD_E return wait movlw 0xC7 ; 1ms Warteschleife, wird "loop-fach" ausgeführt movwf d1 movlw 0x01 movwf d2 Delay_0 decfsz d1, f goto $+2 decfsz d2, f goto Delay_0 goto $+1 decfsz loop, F goto wait return main_1 call init call init_LCD main nop goto main END ; directive 'end of program'