Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Setup EUART in PIC16F886

Status
Not open for further replies.

Suraj143

Active Member
I'm confuse with TX/RX pin in EUART module.

In PIC16F873A says both pins must be set to inputs in TRIS register.

But in PIC16F886 says it has not mentioned anything.

Code:
;----------------------------------------------------------------------------------------------
;9600 bps,4MHz
;8 Data Bits, No Parity, 1 Stop Bit
;----------------------------------------------------------------------------------------------
Init_UART		bsf	STATUS,RP0	; B1
			movlw	b'01000000'	; Make UART TX as input
			movwf	TRISC
			bsf	STATUS,RP1	; B3
			clrf	BAUDCTL
			bcf	STATUS,RP1	; B1
			clrf	PIE1
			clrf	PIE2
			movlw	.25		; 9600bps on 4MHz
			movwf	SPBRG
			clrf	SPBRGH
			movlw	b'00100100'	; BRGH=High,TXEN=ON
			movwf	TXSTA
			bcf	STATUS,RP0	; B0
			movlw	b'10000000'	; SPEN=1,CREN=OFF
			movwf	RCSTA
			clrf	PIR1
			clrf	PIR2
 
Last edited:
It does mention it in a note,
Note 1: When the SPEN bit is set the RX/DT I/O pin
is automatically configured as an input,
regardless of the state of the corresponding
TRIS bit and whether or not the EUSART
receiver is enabled. The RX/DT pin data
can be read via a normal PORT read but
PORT latch data output is precluded.
Also in the text,
Setting the SPEN bit of the RCSTA register enables the EUSART and automatically configures the TX/CK I/O pin as an output.


Mike.
 
But Mike in my above code I want to make EUART module as a transmitter.But I have made that TX pin as a input pin in TRIS register.The data wont send.
 
The code snippet above looks correct assuming 4MHz crystal. Maybe your send routine of config is wrong.

Mike.
 
Does it work correctly when the TX pin is configured as an output? I have noticed with the 16F88 that the UART doesn't work until I set the pin directions in the TRIS register. Perhaps the 16F886 also has this bug?
 
Does it work correctly when the TX pin is configured as an output? I have noticed with the 16F88 that the UART doesn't work until I set the pin directions in the TRIS register. Perhaps the 16F886 also has this bug?

You are correct.Enhanced PICs it has this problem.For the TX pin it has to be set as an output pin.But in earlier 628A series it works on both conditions.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top