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.

8051 reads 7-bit - possible?

Status
Not open for further replies.

DrWhoF

Advanced Member level 1
Joined
May 6, 2005
Messages
402
Helped
24
Reputation
48
Reaction score
11
Trophy points
1,298
Activity points
4,388
How to make 8051 microcontroller read a device with the following serial port setup:
Speed: 2400bps
Parity: EVEN
Bit Length: 7
Stop Bit: 1

Is it possible?

Thanks
DrWho
 

Yes, just use the 8-bit mode and then handle the parity bit in your code.
Here you will find an example:
**broken link removed**
 

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
hai
actually the 8th bit is the parity
which you can remove easly
and the rest is the actual data
just take the data to accumulator
clear the D7
that's all

sun
 

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
Try this short code with Hyperterminal (2400,7, E, 1) ..
Code:
$NOPAGING
$MOD252	


	ORG	 	0000H 

	MOV 		TMOD, #20h
	MOV 		SCON, #52h
	MOV		PCON, #80h
	MOV 		TH1, #0E8h		; 2400bps & SMOD=1
	MOV 		TCON, #40h		; SETB TR1

	MOV 		50h, #'H'
	MOV 		51h, #'E'
	MOV 		52h, #'L'
	MOV 		53h, #'L'
	MOV 		54h, #'O'
	MOV 		55h, #10d		; LF 
	MOV 		56h, #13d		; CR
;-------------------------------------------------
;Main Program 
;-------------------------------------------------

SERIAL:	
	LCALL 	Char_Get
	CPL		P1.0
	LCALL		Ser_Out

	LCALL 	Char_Sent
	SJMP		SERIAL

;-------------------------------------------------
;Character sent subroutine 
;-------------------------------------------------

Char_Sent: 
	MOV		R0, #07h		; Loop counter ..
	MOV		R1, #50h

S_Loop:
	MOV 		A, @R1
	LCALL		Ser_Out
	INC		R1
	DJNZ		R0, S_Loop
	RET

Ser_Out:
	JNB		TI, $
	CLR		TI
	MOV		SBUF, A
	RET
 
;-------------------------------------------------
;Character receive subroutine 
;-------------------------------------------------

Char_Get: 
	JNB 		RI, char_get
	CLR		RI
	MOV 		A, SBUF
	CLR		ACC.7
	RET

; --------------------------------------------------

	END

When you press any key it sends this key + HELLO ..
If it works well you can use the same UART setup in your code ..

Regards,
IanP
 

    DrWhoF

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top