Searching \ for '[PIC]: Port A output woes' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=output
Search entire site for: 'Port A output woes'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Port A output woes'
2002\05\14@191858 by Pic Dude

flavicon
face
I must be doing something wrong here, but the problem eludes me...

Using 16F872, Port A is setup as all outputs, and all digital, but
when I write 0xFF to Port A, RA<4> does not come go high.  I've
tested the LED, the resistor, and even the breadboard connection
by jumpering a wire from the IC pin to the LED.

RA4 also serves as T0CKI (external clock), but I have that setup
for internal clock, and am successfully using TMR0 to generate
a clock pulse, so that confirms to me that it's not configuring that
pin as an external clock input.

Here are snippets of the code, and there are no other references
to PORTA anywhere in the code.  See the line marked "XXX" in the
comment field -- this was added to test PORTA configuration when
I first saw the odd results.


       LIST P=16F872
       INCLUDE "p16f872.inc"
       ERRORLEVEL -224
       __CONFIG _PWRTE_ON & _LP_OSC & _WDT_OFF & _LVP_OFF

       CBLOCK  H'20'

<code snipped>

       ORG     0x00
       goto    Init

       ORG     0x04
       goto    ISR


;-------------------------------------------------------------------
;   Initialization section
;-------------------------------------------------------------------

Init:
       bsf     STATUS,RP0      ; Select bank 1
       bcf     STATUS,RP1      ; ...

       movlw   B'00000110'
       movwf   ADCON1          ; Port A is all digital
       movlw   B'00000000'
       movwf   TRISA           ; Port A is all outputs
       movlw   B'11100000'
       movwf   TRISB           ; RB7:5 are inputs, RB4:0 outputs
       movlw   B'00000000'
       movwf   TRISC           ; Port C is all outputs

       movlw   B'00000100'     ; Port B pullups enabled, internal ...
       movwf   OPTION_REG      ; ... clock, prescaler 1:32

<code snipped>

;---------------------------------------------------------------------
;   Main code routine
;---------------------------------------------------------------------

Main:
       ;----- Ensure that we're in bank 0 -----
       bcf     STATUS,RP0      ; Select bank 0
       bcf     STATUS,RP1      ; ...


       ;----- Primary loop -----
MainLoop:

<code snipped>

;***** TEMP DEBUG ***** Show value of button states on PORT A
       clrf    TMPREG2
       btfsc   BTN_MODE,7
       bsf     TMPREG2,0
       btfsc   BTN_MODE,6
       bsf     TMPREG2,1
       btfsc   BTN_UP,7
       bsf     TMPREG2,2
       btfsc   BTN_UP,6
       bsf     TMPREG2,3
       btfsc   BTN_DOWN,7
       bsf     TMPREG2,4
       btfsc   BTN_DOWN,6
       bsf     TMPREG2,5
       movf    TMPREG2,W
       movlw   H'FF'           ; XXX Override and light up all PORT-A LED's.
       movwf   PORTA
;*****

       goto    MainLoop

<code snipped>



For grins, I tried another 16F872, but got the same odd
results, so it's not the chip.
Thanks for any thoughts...

Cheers,
-Neil.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\05\14@193340 by Tony Nixon

flavicon
picon face
Pic Dude wrote:
>
> I must be doing something wrong here, but the problem eludes me...
>
> Using 16F872, Port A is setup as all outputs, and all digital, but
> when I write 0xFF to Port A, RA<4> does not come go high.  I've
> tested the LED, the resistor, and even the breadboard connection
> by jumpering a wire from the IC pin to the LED.

You're not doing anything wrong as such.

RA4 is an open collector output and can only pull low. It goes open
circuit otherwise and if you need a logic 1, you need a pullup resistor.

Check out the PORTA info in the data sheet to see more.


--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
spam_OUTsalesTakeThisOuTspambubblesoftonline.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\05\14@195736 by Pic Dude

flavicon
face
I did come across "open-drain" in the datasheet, but
did not fully understand its implications.

So you're suggesting that it will float (or close) for
logic 1 output, and actually go to low for logic 0 output.

I can live with that.  All I'm using it for is some
extra debugging indicators right now.

Thanks,
-Neil.



{Original Message removed}

2002\05\14@200843 by John Dammeyer

flavicon
face
Open Drain means there is nothing to pull the output up to +5V inside
the uC.  That allows a number of devices to share that output and any
one device can pull it low without damaging the others.  To see a logic
high output you need to tie the pin to +5V through a 2K .. 50K resistor.

John Dammeyer



Wireless CAN with the CANRF module.
www.autoartisans.com/documents/canrf_prod_announcement.pdf
Automation Artisans Inc.
Ph. 1 250 544 4950


> {Original Message removed}

2002\05\14@201647 by Jinx

face picon face
> So you're suggesting that it will float (or close) for
> logic 1 output, and actually go to low for logic 0 output.

It doesn't "float" as such. If you look at the data sheet you'll
see that other i/o pins have an N-ch FET to Vss and a P-ch
FET to Vcc. An open drain pin has no P-ch FET, so has
nothing to pull it high when you drive it. It needs an external
component, usually a resistor, to go high. Two other points
to consider - there is no protection diode to Vcc (only to Vss)
and the maximum voltage on such a pin is 8.5V, compared
to Vcc +0.3V for a normal i/o pin

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\05\14@211140 by hard Prosser

flavicon
face
Isn't Port A,  Bit 4 the open drain one?
- If so it requires a pullup resistor.

Richard P




I must be doing something wrong here, but the problem eludes me...

Using 16F872, Port A is setup as all outputs, and all digital, but
when I write 0xFF to Port A, RA<4> does not come go high.  I've
tested the LED, the resistor, and even the breadboard connection
by jumpering a wire from the IC pin to the LED.

RA4 also serves as T0CKI (external clock), but I have that setup
for internal clock, and am successfully using TMR0 to generate
a clock pulse, so that confirms to me that it's not configuring that
pin as an external clock input.

Here are snippets of the code, and there are no other references
to PORTA anywhere in the code.  See the line marked "XXX" in the
comment field -- this was added to test PORTA configuration when
I first saw the odd results.


       LIST P=16F872
       INCLUDE "p16f872.inc"
       ERRORLEVEL -224
       __CONFIG _PWRTE_ON & _LP_OSC & _WDT_OFF & _LVP_OFF

       CBLOCK  H'20'

<code snipped>

       ORG     0x00
       goto    Init

       ORG     0x04
       goto    ISR


;-------------------------------------------------------------------
;   Initialization section
;-------------------------------------------------------------------

Init:
       bsf     STATUS,RP0      ; Select bank 1
       bcf     STATUS,RP1      ; ...

       movlw   B'00000110'
       movwf   ADCON1          ; Port A is all digital
       movlw   B'00000000'
       movwf   TRISA           ; Port A is all outputs
       movlw   B'11100000'
       movwf   TRISB           ; RB7:5 are inputs, RB4:0 outputs
       movlw   B'00000000'
       movwf   TRISC           ; Port C is all outputs

       movlw   B'00000100'     ; Port B pullups enabled, internal ...
       movwf   OPTION_REG      ; ... clock, prescaler 1:32

<code snipped>

;---------------------------------------------------------------------
;   Main code routine
;---------------------------------------------------------------------

Main:
       ;----- Ensure that we're in bank 0 -----
       bcf     STATUS,RP0      ; Select bank 0
       bcf     STATUS,RP1      ; ...


       ;----- Primary loop -----
MainLoop:

<code snipped>

;***** TEMP DEBUG ***** Show value of button states on PORT A
       clrf    TMPREG2
       btfsc   BTN_MODE,7
       bsf     TMPREG2,0
       btfsc   BTN_MODE,6
       bsf     TMPREG2,1
       btfsc   BTN_UP,7
       bsf     TMPREG2,2
       btfsc   BTN_UP,6
       bsf     TMPREG2,3
       btfsc   BTN_DOWN,7
       bsf     TMPREG2,4
       btfsc   BTN_DOWN,6
       bsf     TMPREG2,5
       movf    TMPREG2,W
       movlw   H'FF'           ; XXX Override and light up all PORT-A
LED's.
       movwf   PORTA
;*****

       goto    MainLoop

<code snipped>



For grins, I tried another 16F872, but got the same odd
results, so it's not the chip.
Thanks for any thoughts...

Cheers,
-Neil.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2002\05\15@130606 by Pic Dude

flavicon
face
Ahhh... that's better.  I did also find another link on the
web that explained use of the open-drain pin.  BTW, I did
use a resistor and managed to get it working properly.

Thanks much,
-Neil.



{Original Message removed}

2002\05\16@083957 by Olin Lathrop

face picon face
> Using 16F872, Port A is setup as all outputs, and all digital, but
> when I write 0xFF to Port A, RA<4> does not come go high.

RA4 has an open drain output driver.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2002 , 2003 only
- Today
- New search...