ON 20080123@10:04:19 AM at page: http://www.piclist.com/io/lcd/pic.htm#39470.0722685185 James Newton[JMN-EFP-786] removed post 39470.0722685185 with comment: 'This question should be placed on the 7 segment page or on a forum for PICBasic.' |Delete 'virgieddie@gmail.com asks:
Can Someone please help me with my project. I'm a student and am supposed to come up with PIC Temperature monitor project using PIC 16F84 as the MCU and DS1820 as the digital temperature sensor. The problem i'm having so far is of communicating with a serial 4-digit 7 segment display (of make TSM6655B). it has three main pin; the clock, seria data and data enable pins. i'm using proton IDE to come up with the code. I have tried to use the SHout command and im not sure if I've used correctly. and i dont know how to use the data enable pin. If ever you want to help me with a few lines of code please use PICBasic for Proton IDE. thanx very much in advance
Simple routines for controlling a HD44780 display. Useful if you are adding a display to an old project. The data bus and control lines can use any pin. It works just fine on pic 16f677.ON 20080126@4:42:00 AM at page: http://www.piclist.org/techref/io/lcd/lcd.asm.htm#39473.1958217593 Stefan Johansson[SJ-telia-G32] Code:
<xmp> ;********************************************************************** ; Simple routines for controlling a HD44780 display * ; Useful if you are adding a display to an old project. * ; The data bus and control lines can use any pin. * ; * ;********************************************************************** ; * ; Filename: lcd.asm * ; Date: 20080126 * ; File Version: 1.0 * ; * ; Author: Stefan Johansson * ; tessier at telia dot com * ; * ;********************************************************************** ; * ; Usage: #include <lcd.asm> * ; call LCDINIT ; Initialize LCD * ; * ; movlw 0x05 * ; call LCDADD ; Goto lcd adress 0x05 * ; * ; movlw 'A' * ; call LCDSEND ; Write character A * ;********************************************************************** ; * ; Variables: D0 * ; D1 * ; D2 * ; LCDTmp * ; * ;********************************************************************** ; * ; Notes: This was written and compiled for PIC 16f677. * ; Modification might be needed for other models. * ; Any comments, questions or improvements... mail me * ; * ;********************************************************************** ; LCD control lines ; Modify to match your project #define LCD_D4 PORTC, 0 ; 4 data lines #define LCD_D5 PORTC, 1 #define LCD_D6 PORTC, 2 #define LCD_D7 PORTC, 3 #define LCD_RS PORTC, 4 ; 0 = Command, 1 = Data #define LCD_E PORTC, 5 ; 1 to send data ;************************************************************* ; Initialize LCD functions ;************************************************************* LCDINIT ; Set correct TRIS values for LCD ports bsf STATUS, RP0 ;Bank 1 bcf LCD_RS bcf LCD_E bcf LCD_D4 bcf LCD_D5 bcf LCD_D6 bcf LCD_D7 bcf STATUS, RP0 ;Bank 0 movlw 0x14 ; Initial delay, probably not needed... call delay ; Forced LCD initialization bcf LCD_RS ; Set command mode bcf LCD_E bsf LCD_D4 bsf LCD_D5 bcf LCD_D6 bcf LCD_D7 call PULSE call delay_1ms call delay_1ms call PULSE call PULSE ; Send the command to select 4-bit mode first bcf LCD_D4 call PULSE ; Function set ; Format: xxxDNFxx D: 1= 8-bit, 0= 4-bit (use 4-bit!) movlw b'00101000' ; N: 1= 2 lines, 0= 1 line call LCDSEND ; F: 1= 5x10 font, 0= 5x8 font ; Display control ; Format: xxxxxDCB D: Display on(1)/0ff(0) movlw b'00001100' ; C: Cursor on(1)/0ff(0) call LCDSEND ; B: Blink on(1)/0ff(0) ; Entry mode set ; Format: xxxxxxIS I: 1= Inc counter, 0= Dec counter movlw b'00000110' ; S: 1= "Accompanies display shift" call LCDSEND ; Cursor or display shift ; Format: xxxxSRxx S: 1= Display shift, 0= Cursor move movlw b'00010000' ; R: 1= Shift right, 0= Shift left call LCDSEND movlw b'00000001' ; Clear screen call LCDSEND bsf LCD_RS ; Set data mode RETURN ;************************************************************* ; Moves "cursor" ;************************************************************* LCDADD bcf LCD_RS ; Command mode iorlw 0x80 ; Goto DDRAM adress call LCDSEND bsf LCD_RS ; Data mode call delay_1ms ; Takes a couple of ms RETURN ;************************************************************* ; Sends contens of W to display ;************************************************************* LCDSEND ; Sends character in W to lcd. Does not alter RS line! movwf LCDTmp bcf LCD_D4 bcf LCD_D5 bcf LCD_D6 bcf LCD_D7 btfsc LCDTmp, 7 bsf LCD_D7 btfsc LCDTmp, 6 bsf LCD_D6 btfsc LCDTmp, 5 bsf LCD_D5 btfsc LCDTmp, 4 bsf LCD_D4 call PULSE bcf LCD_D4 bcf LCD_D5 bcf LCD_D6 bcf LCD_D7 btfsc LCDTmp, 3 bsf LCD_D7 btfsc LCDTmp, 2 bsf LCD_D6 btfsc LCDTmp, 1 bsf LCD_D5 btfsc LCDTmp, 0 bsf LCD_D4 call PULSE return ;************************************************************* ; Pulse enable line ;************************************************************* PULSE ; Pulse Enable. bsf LCD_E nop ; Increase the delay here if you get nop ; problems with high clock speed nop nop bcf LCD_E call delay_1ms call delay_1ms return ;************************************************************* ; Clears display ;************************************************************* LCDCLR ; clears the entire display bcf LCD_RS ; Set command mode movlw b'00000001' ; Clear screen call LCDSEND bsf LCD_RS ; Set data mode RETURN ;************************************************************* ; Calls the delay_1ms W times ;************************************************************* delay movwf d0 dly_loop call delay_1ms decfsz d0, F goto dly_loop return ;************************************************************* ; 1ms delay. ; Modify this to match your processor speed. ; http://www.piclist.org/techref/piclist/codegen/delay.htm ;************************************************************* delay_1ms movlw 0xC7 movwf d1 movlw 0x01 movwf d2 Delay_0 decfsz d1, f goto $+2 decfsz d2, f goto Delay_0 ;2 cycles goto $+1 return </xmp>ON 20080128@4:58:02 AM at page: http://www.piclist.org/techref/io/lcd/lcd.asm.htm# Stefan Johansson[SJ-telia-G32] change |Replace: '' with: '' ON 20080128@4:58:28 AM at page: http://www.piclist.org/techref/io/lcd/lcd.asm.htm# Stefan Johansson[SJ-telia-G32] I have agreed to maintain this page. ON 20080131@5:09:12 PM at page: http://www.massmind.org/io/lcd/panel1.htm#39478.062662037 James Newton[JMN-EFP-786] removed post 39478.062662037 |Delete ' Hi, I have just ordered a couple. looking forward ;) Would you recommand a hard or soft cae to protect from splashes? Thank,