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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/26/07 15:48
Modified:
  12/26/07 15:51

Read: times


 
#148716 - here is the code
Responding to: ???'s previous message
;receiver code for RLP434A module
$mod51
;
;port 3 pinouts
Ser_RX	equ	p3.0	;Serial RX from RF Module
Ser_TX	equ	p3.1	;Serial TX to Max232
LED 		equ	p3.5	;

count1	equ	11h	;
count		equ	10h	;
;----------------------------------------------------
org	00000h
Reset:
	sjmp	Start			; 
Start:
	MOV   SP,#07h          	; 
	mov	a,#0FFh		; 
	mov	p1,a			;
	mov	p3,a			;
;----------------------------------------------	
Main:	
	lcall	receive		;receive data from RF module
	lcall	transmit		;send it to Uart @ 2400 baud
	sjmp	Main	
;----------------------------------------------
; The serial baud rate is determined by the 
; processor crystal, and
; this constant which is calculated as: 
;(((crystal/baud)/12) -5) / 2
; (((11059200/2400)/12) -5) / 2
BITTIM	equ	189		;2400 Baud (@ 11.0592MHZ)
;----------------------------------------------	
;* "Bit-bang" serial I/O functions for the 8051.
;* Dave Dunfield - May 17, 1994
;----------------------------------------------	
receive:
	JB	SER_RX,$		;Wait for start bit
	MOV	R2,#BITTIM/2	;Wait 1/2 bit-time
	DJNZ	R2,$			;To sample in middle
	JB	SER_RX,receive	;Insure valid
	MOV	R3,#8			;Read 8 bits
receive1:
	MOV	R2,#BITTIM		;Wait full bit-time
	DJNZ	R2,$			;For DATA bit
	MOV	C,SER_RX		;Read bit
	RRC	A			;Shift it into ACC
	DJNZ	R3,receive1		;read 8 bits
      CLR  	C			;
	RET				;go home
;----------------------------------------------	
;Transmit character in A via PC TXD line
transmit:
	CLR	SER_TX	;Drop line for start bit
	MOV	R2,#BITTIM	;Wait full bit-time
	DJNZ	R2,$		;For START bit	
	MOV	R3,#8		;Send 8 bits
OutChar1:
	RRC	A		;Move next bit into carry
	MOV	SER_TX,C	;Write next bit
	MOV	R2,#BITTIM	;Wait full bit-time
	DJNZ	R2,$		;For DATA bit
	DJNZ	R3,OutChar1	;write 8 bits
	SETB	SER_TX	;Set line high
	RRC	A		;Restore ACC contents
	MOV	R2,#BITTIM	;Wait full bit-time
	DJNZ	R2,$		;For STOP bit
	RET			;
;----------------------------------------------
END


List of 19 messages in thread
TopicAuthorDate
8051 Port Pin wont go low            01/01/70 00:00      
   Try this            01/01/70 00:00      
   here is the schematic            01/01/70 00:00      
      RC-reset is wrong!            01/01/70 00:00      
   That RST schematic is for AVR , which            01/01/70 00:00      
   yes schematic shows wrong reset            01/01/70 00:00      
      Low state current            01/01/70 00:00      
   I tried this            01/01/70 00:00      
      You should use CMOS            01/01/70 00:00      
         here is the code            01/01/70 00:00      
            signal source is inadequate, code is irrelevant            01/01/70 00:00      
      The 7407 has the same problem ...            01/01/70 00:00      
   would this work?            01/01/70 00:00      
      why not 'H' why 'HC"?            01/01/70 00:00      
         its what I have            01/01/70 00:00      
         H ??? Didn\'t they quit making that in the \'70s?            01/01/70 00:00      
   74HC04 is working            01/01/70 00:00      
      Single transistor            01/01/70 00:00      
   these superfluous facts in the datasheet            01/01/70 00:00      

Back to Subject List