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.

RA4 not working???

Status
Not open for further replies.

Alverick

New Member
Hi, I'll get to the point: I program PORTA as output, and everytime I write a logic 1 in pin 4 (RA4/T0CKI) it doesn't change. I'm simulating my program in Labcenter ISIS v5 ... it's not the first time that happens, and not only with the 16f628, but with 16f877 and 16f84 (those are the only ones that I was programming lately).. Here is my code:

Code:
LIST	P=16F628
	
	INCLUDE	<p16f628.inc>

	__CONFIG _CP_OFF & _BODEN_OFF & _INTRC_OSC_NOCLKOUT & _DATA_CP_OFF & _LVP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _XT_OSC & _ER_OSC_NOCLKOUT

CounterA	EQU	20h
CounterB	EQU	21h
CounterC	EQU	22h

		ORG	0x00		
		
		goto	INICIO		



		ORG	0x04		

		goto	inter

		

INICIO		clrf	PORTB		
		clrf	PORTA		

		bsf	RCSTA,SPEN	

		movlw	0x07
		movwf	CMCON

		movlw	b'11000110'
		movwf	OPTION_REG

		bsf	STATUS,RP0	
		bcf	STATUS,RP1
		
		movlw	b'00000011'	
		movwf	TRISB		
		movlw	0xFF
		movwf	TRISA

		movlw	b'00100100'	
		movwf	TXSTA		
		movlw	.25		
		movwf	SPBRG
		bsf	PIE1,RCIE	
		bcf	STATUS,RP0	
		
		bsf	RCSTA,SPEN	
		
		movlw	b'10010000'	
		movwf	RCSTA		
		
		bsf	STATUS,RP0
		bcf	STATUS,RP1
		bsf	TXSTA,TXEN
		bcf	STATUS,RP0

stt		movlw	b'11010000'	
		movwf	INTCON		
	
BUCLE		goto	BUCLE		

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

inter		btfsc	PIR1,RCIF	
		goto	getdat
		btfsc	INTCON,INTF	
		goto	senddat
		goto	stt

getdat		bcf	PIR1,RCIF	

		bsf	STATUS,RP0
		movlw	0xE0
		movwf	TRISA
		bcf	STATUS,RP0

		movf	RCREG,W		
		movwf	PORTA		
		goto	stt

senddat		bsf	STATUS,RP0
		movlw	0xFF
		movwf	TRISA
		bcf	STATUS,RP0

		movfw	PORTA
		movwf	TXREG

		bsf	STATUS,RP0	
		bcf	STATUS,RP1
COMP_TX		btfss	TXSTA,TRMT	
		goto	COMP_TX
		bcf	STATUS,RP0	
		goto 	stt
		


		
;PIC Time Delay = 1,0000020 s with Osc = 4 MHz

PDelay		movlw	D'6'
		movwf	CounterC
		movlw	D'24'
		movwf	CounterB
		movlw	D'168'
		movwf	CounterA
loop		decfsz	CounterA,1
		goto	loop
		decfsz	CounterB,1
		goto	loop
		decfsz	CounterC,1
		goto	loop
		return
		
		END

BTW, the __CONFIG is ok? or i'm doing something wrong there? :S
Greets!!
 
Do you have a pull-up resistor connected between RA4 and Vcc?
RA4 is an open drain output.
 
Does this mean...

1. Is it really to add a pull up resistor to R4 for configuring it as an output... ?

2. One more thing concerning with this... :

What's the reason behind it...?:eek:

that RA4 is a schmitt trigger input and an open drain output while....

other pins are TTL inputs and CMOS outputs...



Regards,

simran..
 
Last edited:
simrantogether said:
1. Is it really to add a pull up resistor to R4 for configuring it as an output... ?

Not as such, like any other I/O pin you configure it in the TRIS register. However, as you already know, it's an open drain output - so to make it appear as a normal ouput you need a pull up resistor - RA4 can only sink current, not source it.

2. One more thing concerning with this... :

What's the reason behind it...?:eek:

To make it more versatile, an open drain output can be very useful, as can a schmitt input.
 
sorry sir...

YES.. i got it...

The purpose of schmitt trigger is.. that to give output high when the voltage is more than a certain value..

and lower when input is lower than certain value... as seen here...

Good technique...:)
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top