Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/21/06 13:31
Read: times


 
#128353 - Here's the entire code....
Responding to: ???'s previous message
 Note that the LCD is not the issue. I can properly display
data from ADC, Keypad, Ex.RAM, etc. 
Also, ignore some of the equates that are not used in the
code, I just left them in there so i can remember them
 THanks again




;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ASSEMBLER CONTROLS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$MOD31
$DEBUG
$NOPAGING
$PAGEWIDTH(132)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;EQUATES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

LCD_RS   EQU P3.5
LCD_EN   EQU P3.4
LCD_DATA EQU P1
flag1	  EQU 21h
STORE	  EQU 20H	
CLEAR	EQU	01H
HOLDKEY   EQU 40h 
BLINKCUR  EQU 0Dh
OFFCUR	  EQU 0Ch
BUFFER	EQU	24H
LINE	EQU	R1 
COUNT	EQU	R2
RESET_VALUE EQU 15536

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; INTERRUPT VECTORS/ORGs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	ORG 	0000H			; reset interrupt vector
	LJMP 	MAIN			; MAIN MODULE

	ORG 0023h			;card reader interrupt vector
	LJMP	CARDswipe	;card reader subroutine
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;MAIN MODULE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	ORG 0030H

MAIN:MOV 	 P1,#00h					;LCD
	 MOV 	 TMOD,#021h	;sets T1 as 8-bit reload and T0 as 16 bit 
	 mov 	 IE,#81h
	 MOV	 TCON,#14H
	 MOV      SCON,#050h     ;SETS SERIAL PORT TO MODE 1, ENABLES RECEIVER
     MOV      A,PCON
     SETB     ACC.7          ;Set Bit 7 SMOD
     MOV      PCON,A
     MOV      TH1,#0F3H      ;sets reload value for baud rate
     SETB     TR1			;starts timer
	
	
	LCALL INIT_LCD
	LCALL DELAY_1S
	MOV		A,R2			; bring in SBUF data			
	MOV	R0,	#01h			;clear the screen
	LCALL	wrLCDcom
	MOV	R0,	#81h			; position cursor
	LCALL	wrLCDcom
	MOV		R0, A
	LCALL	WRLCDDATA		; display SBUF on the screen
	LCALL 	DELAY_1S
	
	LJMP	MAIN


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; LCD SUBROUTINES FOR HOME MED SYSTEM
; NOVEMBER 2, 2006
; DIGITAL III
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PLACE CURSOR CHANGES ADDRESS OF CURSOR LOCATION
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

placeCur: dec acc 			; acc=0 for line=1
	jnz line2 			; if acc=0 then first line
	mov a, b
	add a, #080h 			; construct control word for line 1
	sjmp setcur
line2:	mov a, b
	add a, #0C0h 			; construct control word for line 2
setcur:	mov r0, a 			; place control word
	lcall wrLCDcom 			; issue command
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WRITE LCD DATA
; MOVES THE CONTENTS OF R0 TO LCD PORT TO WRITE DATA WORD ON LCD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

wrLCDdata:clr LCD_EN
	setb LCD_RS ; select send Data
	mov LCD_DATA, r0 ; load command into port
	lcall pulseEwait ; pulse the Enable line
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WRITE LCD COMMAND
; MOVES THE CONTENTS OF R0 TO LCD PORT TO WRITE COMMAND WORD ON LCD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

wrLCDcom:clr LCD_EN
	clr LCD_RS ; select send Command
	mov LCD_DATA, r0 ; load command into port
	lcall pulseEwait ; pulse the Enable line
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PULSE ENABLE WAIT
; GENERATES POSITIVE PULSE ON LCD ENABLE PIN AND WAITS 5.1ms
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

pulseEwait:clr LCD_EN
	setb LCD_EN ; pulse the Enable line
	clr LCD_EN
	mov LCD_DATA, #0ffh ; prepare port for input
	LCALL DELAY_5_1MS
	LCALL DELAY_5_1MS
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; INITIALIZE LCD
; PERFORMS POWER ON RESET AND SETS FUNCTIONS AND DISPLAY
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

init_LCD:clr LCD_RS ; LCD Register Select line
	clr LCD_EN ; Enable line
	
	mov r0, #30h ; 
	lcall wrLCDcom
	mov r0, #30h ; 
	lcall wrLCDcom
	mov r0, #30h ; 
	lcall wrLCDcom

	mov r0, #38h ; Function Set - 2 lines 5x7 fonts
	lcall wrLCDcom
	mov r0, #0ch ; display ON
	lcall wrLCDcom
	mov r0, #06h ; set Entry Mode
	lcall wrLCDcom ; increment cursor to right, no display shift
	mov r0, #01h ; clear display, home cursor
	lcall wrLCDcom
	ret

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; PRINTS DATA IMMEDIATELY FOLLOWING SUBROUTINE CALL
; ZERO IS DELIMITER
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

prtLCD:pop dph ; pop return address into dptr
	pop dpl
prtNext:clr a ; set offset = 0
	movc a, @a+dptr ; get chr from code memory
	cjne a, #0, chrOK ; if chr = 0 then return
	sjmp retPrtLCD
chrOK:mov r0, a
	lcall wrLCDdata ; send character
	inc dptr ; point at next character
	ajmp prtNext ; loop till end of string
retPrtLCD:mov a, #1h ; point to instruction after string
jmp @a+dptr ; return with a jump instruction


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ONE SECOND DELAY LOOP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DELAY_1S:MOV R7,#20			;LOOP COUNT
	MOV TH0,#3CH			;20*50,000us
	MOV TL0,#0B0H
	SETB TR0
WAIT:	JNB TF0,$
	CLR TF0
	DJNZ R7,WAIT
	CLR TR0
	RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; TWO SECOND DELAY LOOP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DELAY_2S:MOV R7,#40			;LOOP COUNT
	MOV TH0,#3CH			;40*50,000us
	MOV TL0,#0B0H
	SETB TR0
WAIT2:	JNB TF0,$
	CLR TF0
	DJNZ R7,WAIT2
	CLR TR0
	RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 5.1 MILLISECOND DELAY LOOP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DELAY_5_1MS:MOV TH0,#0ECH		;5.1ms
	MOV TL0,#14H
	SETB TR0
	JNB TF0,$
	CLR TF0
	CLR TR0
	RET

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 250 MILLISECOND DELAY LOOP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DELAY_250mS:MOV R7,#5			;LOOP COUNT
	MOV TH0,#3CH			;5*50,000us
	MOV TL0,#0B0H
	SETB TR0
WAIT3:	JNB TF0,$
	CLR TF0
	DJNZ R7,WAIT3
	CLR TR0
	RET
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 100 MILLISECOND DELAY LOOP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DELAY_100mS:MOV R7,#2			;LOOP COUNT
	MOV TH0,#3CH			;2*50,000us
	MOV TL0,#0B0H
	SETB TR0
WAIT1:	JNB TF0,$
	CLR TF0
	DJNZ R7,WAIT1
	CLR TR0
	RET
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Card Reader Subroutine
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CARDswipe: 	push dph
			push dpl
			push acc
swipe:		JNB     RI,swipe
			CLR		RI
			MOV	A,SBUF
			MOV R2, A
		    pop acc
		    pop dpl
		    pop dph
RETI


END



List of 23 messages in thread
TopicAuthorDate
Serial interface- Displaying SBUF data on LCD.            01/01/70 00:00      
   what device?            01/01/70 00:00      
      Just the 'integral part' Part of code            01/01/70 00:00      
         you still did not tell the derivative            01/01/70 00:00      
   Formatted Code            01/01/70 00:00      
      Missing code            01/01/70 00:00      
   Delay            01/01/70 00:00      
      Delay, Baudrate, Freq, etc.            01/01/70 00:00      
         Missing Code            01/01/70 00:00      
            Here's the wrLCDcom SR            01/01/70 00:00      
               is DELAY_5_1MS timer based?            01/01/70 00:00      
                  Yes DELAY_5_1MS is timer based            01/01/70 00:00      
                     so, you call one device generating an interrupt fr            01/01/70 00:00      
                        Already tried that            01/01/70 00:00      
                           then keep it that way            01/01/70 00:00      
                  Here's the entire code....            01/01/70 00:00      
                     I quick look, not an analysis            01/01/70 00:00      
   Have a look at this            01/01/70 00:00      
      Deriviative???            01/01/70 00:00      
         Derivative            01/01/70 00:00      
            Oops... Derivative..gotcha            01/01/70 00:00      
               OK            01/01/70 00:00      
                  TI & RI            01/01/70 00:00      

Back to Subject List