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.

Issue with PIC 16F627 RB2 line with UART enabled

Status
Not open for further replies.

gbsallery

New Member
Hello all,

I'm new to this forum, but just wondering if I could pick your assorted brains on a PIC related issue (no pun intended, honest).

I'm building PWM LED multiplex driver using a PIC 16F627A; thanks to other posts on this forum I've got my driver transistors working correctly for rows and columns, and my software PWM code is working nicely. However, I am unable to get the column attached to pin RB2/TX/CK to function; I suspect that this is because I am using the PIC's UART to talk to a host computer over RS232. Although the port is set as an output in the TRISB register, I have a nagging feeling that enabling the UART forces this to be the serial transmit pin. Is this the case?

Thanks,

Gavin
 
From the schematic of the RB2 I/O pin, once the serial port is enabled and TRIS register is set for output, the TX data from the USART prevails over the output latch.
 
Ah, thanks. Those diagrams are a little beyond me, I must be rusty...

On a similar note, I'm not getting any ouput from RA4 (RA7,6,3-0 work okay). Could this be something similar? I'm not (intentionally) using the comparator, so I don't think that's it... my initialisation code is shown below, in case that helps.

Gavin


Code:
; ****************************
; ** RESET : Boot from here **
; ****************************
RESET	MOVLW	B'00000111' ;Disable comparators
		MOVWF	CMCON
		;
		BSF		STATUS,RP0	;Switch to register bank 1
		MOVLW	B'11010111'
		MOVWF	OPTION_REG
		;
		CLRF	INTCON		;Disable interrupts
		MOVLW	B'00000010'	;RB1 is an input
		MOVWF	TRISB		
		MOVLW	B'00100000'	;All RA ports are outputs, except RA5
		MOVWF	TRISA
;		MOVLW	D'1'		;SPBRG=1 for 115,200 baud (4MHz clock)
		MOVLW	D'12'		;SPBRG=12 for 19,200 baud
		MOVWF	SPBRG
		MOVLW	B'00000100'	;BRGH=High
		MOVWF	TXSTA
		BCF		STATUS,RP0	;Switch back to register bank 0
		MOVLW	B'10010000'	;Enable asynch serial port
		MOVWF	RCSTA
		CLRF	PORTB
		CLRF	PORTA
		CLRF	PACKET_PTR
		CLRF	DIGIT_STAT
		CLRF	PWM_PTR
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top