> Wishing for some simple example C or ASM code that just > wakes the display up and throws characters & strings at it. > All suggestions welcome. Joe ------------------- PIC18F, LCD data B<7:4> clrscrn macro ;clear LCD movlw 0x01 call write_c endm lcd_pos macro litval ;set print address movlw litval-1 call address endm disp macro litval ;display character movlw litval call write_d endm dispw macro ;display WREG call write_d endm display macro var ;load TBLPTR with string address movlw upper(var) ;for LCD display movwf tblptru movlw high(var) movwf tblptrh movlw low(var) movwf tblptrl tblrd*+ call get_txt endm ln1 =3D 0x00 ;LCD line start addresses ln2 =3D 0x40 strings =3D 0x0f00 ;LCD strings storage ;example useages call lcd_init ;initialise clrscrn ;clear screen display initing ;print "Initialising" ;---- movff date_m,temp0 call _2digit ;convert 'month number' to ASCII lcd_pos ln1+.10 ;set print position, line 1, col 10 movfw dgt ;print tens @ 1.10 dispw movfw dgu ;print units @1.11 dispw ;---- call line2 disp "A" ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ; Initialise LCD screen ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D lcd_init bcf rs call write30 call msdelay ;delay > 4.1ms call msdelay call msdelay call msdelay call msdelay call write30 call msdelay ;delay > 100us call write30 call msdelay ;delay > 100us movlw b'00100000' ;20, functions as needed call write_c movlw b'00001000' ;08 call write_c movlw b'00001100' ;0c call write_c movlw b'00000110' ;06 call write_c return write30 movfw portb andlw b'00001111' addlw b'00110000' movwf latb usec ;1us delay bsf en usec bcf en usec return ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ; LCD commands, 4-bit, high nybble ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D line1 movlw 0x00 ;line 1, column 0 call address return line2 movlw 0x40 ;line 2, column 0 call address return address addlw 0x80 ;set high bit of address command call write_c return write_c bcf rs ;write command bra dt_out write_d bsf rs ;write data ;LCD data - latb <4:7> ;Move MSN of data to MSN of PortB, preserve LSN of PortB dt_out movwf tmp_lcd ;save data movfw portb ;read port andlw b'00001111' ;clear MSN, preserve LSN movwf shadowb ;store PortB 0000LSN movfw tmp_lcd ;get MSN of data andlw b'11110000' ;clear unwanted LSN addwf shadowb,w ;add data MSN as shadowb MSN movwf latb ;write to port usec bsf en usec bcf en usec ;Move LSN of data to MSN of PortD, preserve LSN of Portb movfw portb ;read port andlw b'00001111' ;clear MSN, preserve LSN movwf shadowb ;store PortB 0000LSN swapf tmp_lcd,w ;swap display data MSN and LSN andlw b'11110000' ;clear unwanted LSN (old MSN) addwf shadowb,w ;add data LSN as shadowb MSN movwf latb ;write to port usec bsf en usec bcf en usec bsf rw ;set up for Busy Flag read usec bcf rs usec bsf trisb,7 usec bsf en usec btfsc busy bra $-2 bcf trisb,7 usec bcf en usec bcf rw return ;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D org strings get_txt movfw tablat ;get characters until btfsc wreg,7 ;W > 0x7f (ie FF terminator) return dispw ;print W macro tblrd*+ bra get_txt initing db "Initialising....",0xff ready db "Ready ",0xff blank db " ",0xff ----- No virus found in this message. Checked by AVG - www.avg.com Version: 2015.0.5751 / Virus Database: 4311/9368 - Release Date: 03/23/15 --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .