Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AT89S52 interfacing with rf decoder ht12d

Status
Not open for further replies.

kabaza

Junior Member level 3
Joined
Oct 27, 2011
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,459
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.5
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.5
2)Then, from P0 to LCD(8bit mode)
3)Tried writing random words on LCD and worked!
4)HT12D gets correct info!
Code:
;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
 

hai kabaza...

are you sure u are able to read the decoder output?

Because as i referred your code is not configuring the port 3 as input port. Inorder to read your data using port, you have to configure it to input port.

please add the following line of instruction after the ORG instruction

MOV IN, 0x3BH

I hope you will understand the further steps
 

Have you add pull-up resistor to your port 0? and please check your power-on reset and add a 100nF bypass capacitor at VCC to GND. maybe your reset circuit doesn't work properly.
because you use assembly language you don't have to initialize your port as input as long as you never send 0 logic to that port before.
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top