PDA

View Full Version : RA.4 Open collector,...



tazntex
- 24th August 2010, 20:10
First thing, yes I did search the forum on this question although I was certain I already was correct in my thoughts about ra.4 on my 16F628A. Melanie makes it quite clear especially with this post:
http://www.picbasic.co.uk/forum/showthread.php?t=1642

BUT!!!, Using and led with a resistor on my anode going to 3.3V and my cathode to ra.4, does not work, change processors and programmed with my replacement of the pickit3, my new favorite, the pickit2. I think I even made it as simple as possible with this code:

DEFINE OSC 4
CMCON = %00100101
VRCON = %11101100
PAUSEus 10
TRISA = %00000110
TRISB = %11110001
PORTA = %00000000
PORTB = %00000000
OPTION_REG.7 = 0
OPTION_REG.6 = 0
rf var porta.4


main:
low rf
pause 500
high rf
pause 500
goto main

And it still doesn't work. But I did move the cathode to ground and yes the led lit, so the led does work.

Anyhow, this may have sounded like a stupid question but If I don't ask, I'll never learn anything:)
Thanks again especially for all the knowledge I have gained here on this forum.

tazntex
- 24th August 2010, 20:17
I have it working with this code:
DEFINE OSC 4
CMCON=%00000111
VRCON = 0
PAUSEus 10
TRISA = %00000110
TRISB = %11110001
PORTA = %00000000
PORTB = %00000000
OPTION_REG.7 = 0
OPTION_REG.6 = 0
rf var porta.4

main:
low rf
pause 500
high rf
pause 500
goto main

Does it have something to do with me using the comparator on ra.1,ra.2? I have been reading the datasheet and it mentions ra.3,ra.4 in section5.1 PORTA and TRISA Registers, I am already using ra.3 with no problems as an output.

gadelhas
- 24th August 2010, 20:39
Hi;

Try this;

1 - Connect the RA4 Pin with the resistor to VCC;
2 - Connect the anode of the led beetwen the resistor and the RA4 Pin;
3 - Connect the Cathode of the led to GND

And post the result

rsocor01
- 24th August 2010, 21:17
The reason that you need a resistor between RA4 and Vcc, like Gadelhas mentioned above, is because RA4 in that chip is an Open Drain (OD) type.

4743

Robert

tazntex
- 24th August 2010, 21:35
Sorry about the delay getting back to ya'll. Ok, your instructions said:
1 - Connect the RA4 Pin with the resistor to VCC;
2 - Connect the anode of the led beetwen the resistor and the RA4 Pin;
3 - Connect the Cathode of the led to GND

with or without step 2 the led is illuminated.

Thanks for the fast response.

Bruce
- 24th August 2010, 22:00
RA4 is C2OUT with the 1st configuration you had so you couldn't use it for a digital output. With comparators disabled you can.

This should work fine to drive your LED on RA4 ---|<|---/\/\/--VCC.

tazntex
- 24th August 2010, 22:36
Bruce, thats how I have it, However, I have brown out reset enable on my winpic programmer software, tried it with PICkit3, PICkit2 and it won't work, BUT if I turn off the brown out reset manually in WINPIC programmer, It WORKS:)
But I am going from 9v input to my breadboard, then LP2950ACZ-3.3 (3.3V) regulator to my processor, sure would be nice to use the low voltage (brown out).

Any ideas?

Thanks

Bruce
- 24th August 2010, 22:41
If turning an LED on is tripping reset you might want a larger cap on the reg output or larger series resistor for the LED. BOR definitely shouldn't trip unless you're dropping a lot of power.

Edit: Check the datasheet for Vbor. You may already be running marginal.

tazntex
- 24th August 2010, 22:50
I'll do that this evening, Thanks to everyone for your help.

tazntex
- 25th August 2010, 15:54
I did read about the Vbor, but also in the electrical specifications, it state minimum brown out reset voltage is 3.65V. Using a 3.3V regulator I rekon that cuts that out of the picture.

Well, I don't mean to get off of my original thread but since I am here and ya'll are reading this...
When using Darryl Taylors Interrup's and MPASM how does one set the config bits,thats where I can turn it off, I have been using this PBP compiler with sucess :
@ DEVICE PIC16F628a,XT_OSC
@ DEVICE pic16F628a, WDT_OFF
@ DEVICE pic16F628a, PWRT_ON
@ DEVICE pic16F628a, MCLR_ON
@ DEVICE pic16F628a, BOD_OFF
@ DEVICE pic16F628a, LVP_OFF
@ DEVICE pic16F628a, CPD_OFF
@ DEVICE pic16F628a, PROTECT_OFF
I have even opened the 16F628A.INC in the PBP directory and it is turned off with the above added to my code when I compile using MPASM it won't compile, I get a bunch of errors. If I delete the above it compiles fine.
Meanwhile, I am reading Melanie's post again to see what I've missed: http://www.picbasic.co.uk/forum/content.php?r=157-Presetting-Configuration-Fuses-(PIC-Defines)-into-your-Program
Thank you

gadelhas
- 25th August 2010, 15:57
Hi;

You must do it like this;


@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CP_OFF &_PWRTE_OFF

See this post;

http://www.picbasic.co.uk/forum/showthread.php?t=543&page=1&highlight=16f628a

tazntex
- 25th August 2010, 16:51
Thanks Gadelhas for the fast reply, I tried to compile using that and I get this error:


@ __CONFIG _XT_OSC & _WDT_OFF & _MCLRE_ON & _LVP_OFF & _CP_OFF
DEFINE OSC 4
CMCON=%00000111
VRCON = 0
PAUSEus 10
TRISA = %00000110
TRISB = %11110001
PORTA = %00000000
PORTB = %00000000
OPTION_REG.7 = 0
OPTION_REG.6 = 0
rf var porta.4

main:
low rf
pause 500
high rf
pause 500
goto main
Error[118]c:\program~1\testled.asm 83 : overwriting previous address contents (2007)

What does this mean?

Many Thanks

tazntex
- 25th August 2010, 17:14
Perhaps I could use the external brown out protection with the 3.3V regulator as shown on the datasheet, I like the Example2 version.

gadelhas
- 25th August 2010, 18:23
Hi;

To not give that error you need to go to the file of your pic model in the PBP directory and comment that line, like this;


;* 16F628A.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2003 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 11/06/03 *
;* Version : 2.45 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M16F62xA.INC' ; PM header
device pic16F628A, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F628A, r = dec, w = -302
INCLUDE "P16F628A.INC" ; MPASM Header
;__config _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF '- COMENT THIS LINE WITH ";" ATE THE BEGINNING
NOLIST
endif
LIST

tazntex
- 25th August 2010, 19:03
I did see that but just thought that was to easy and I must have been missing something. But I have done what you said and it works.

Thank you very much for your help