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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
01/10/12 22:11
Read: times


 
#185415 - AT89S52 interfacing with rf decoder ht12d
Hello!
I am trying to get AT89s52 to read 4 bits coming from decoder(HT12D)
the bits are read on the AT89s52 from P3.2-->P3.6
I tested and the bits arrive correctly to the decoder.
ALso, the at89s52 is interfaced with lcd 16x2. I tried reading then masking it with no use. Sometimes I get black box or a random number but by changing numbers so to get different from HEX array!
Thanks!!

Summary: 1)4 bits connected from HT12D to p3.2--->p3.6
2)Then, from P0 to LCD(8bit mode)
3)Tried writing random words on LCD and worked!
4)HT12D gets correct info!
;8 bit LCD routines with check busy ;flag before sending data, command to ;LCD        
;*************************************************************
LCD     DATA     P0         ;define LCD data port on port 0
BUSY    BIT      LCD.7       ;define LCD busy flag
E       BIT      P2.5        ;define LCD enable pin on port 2.2
RS      BIT      P2.7        ;define LCD register select pin on port 2.0
RW      BIT      P2.6        ;define LCD read/write pin on port 2.1

IN      DATA     P3          ;define input port
VT     BIT      IN.7  		 ;Valid transmission

;*************************************************************
        ORG      00H

LCD_INIT:
        MOV      A,#38H                ;2 line 5x7
        ACALL    COMMAND    
        MOV      A,#0CH                ;LCD on cursor on
        ACALL    COMMAND
        MOV      A,#01H                ;clear LCD
        ACALL    COMMAND
        MOV      A,#06H                ;shift cursor right
        ACALL    COMMAND

	MOV      DPTR,#HEX
		
	
		 
wait:	JNB      VT,WAIT             ;No valid transmission yet	
        mov      a,#01h
        acall    COMMAND
        mov      a,#87h
        acall    COMMAND
       
        MOV      A,IN				  ;Copy P3 into reg. A	
        
     	ANL      A,00111100B
         RR       A
        RR       A	
        MOVC     A,@A+DPTR
        ACALL    DATA_DISPLAY
	MOV      DPTR,#HEX
	CLR      A
			
     SJMP     wait    
    
;=============================================================
COMMAND:
        ACALL    READY                 ;is LCD ready?
        MOV      LCD,A                 ;issue command code
        CLR      RS                    ;RS=0 for command
        CLR      RW                    ;R/W=0 to write to LCD|
        SETB     E                     ;E=1 for H-to-L pulse
        CLR      E                     ;E=0 ,latch in
        RET
;=============================================================
DATA_DISPLAY:
        ACALL    READY                 ;is LCD ready?
        MOV      LCD,A                 ;issue data
        SETB     RS                    ;RS=1 for data
        CLR      RW                    ;R/W=0 to write to LCD
        SETB     E                     ;E=1 for H-to-L pulse
        CLR      E                     ;E=0 ,latch in
        RET
;=============================================================
READY:
        SETB     BUSY                  ;make P0.7 input port
        CLR      RS                    ;RS=0 access command reg
        SETB     RW                    ;R/W=1 read command reg
;read command reg and check busy flag
BACK:
        CLR      E                     ;E=1 for H-to-L pulse
        SETB     E                     ;E=0 H-to-l pulse
        JB       BUSY,BACK             ;stay until busy flag=0
        RET

delay:   mov r0,#200
loop1:   mov r1,#200
          djnz r1,$
		  djnz r0,loop1
		  ret
;=============================================================
 ORG 200H
 HEX:    DB  '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'  
 
        END

List of 8 messages in thread
TopicAuthorDate
AT89S52 interfacing with rf decoder ht12d            01/01/70 00:00      
   Five pins for reading four signals?            01/01/70 00:00      
      I meant till 3.5            01/01/70 00:00      
   SOLVED!!!            01/01/70 00:00      
      please ...            01/01/70 00:00      
         Sorry!!            01/01/70 00:00      
   Transmission            01/01/70 00:00      
      Why            01/01/70 00:00      

Back to Subject List