View Full Version : RA3 won't get a high level.
selbstdual
- 5th February 2007, 19:50
Hello, I'll put it short:
-PIC 16F628A
-Vdd is 5.04 Volts
-Quarz is available
-PORTB can give a high level.
Problem:
-RA3 doesn't get a high level.
Done so far:
-
Start:
CMCON.0 = 1
CMCON.1 = 1
CMCON.2 = 1
Pause 5000
- Trisa.3 = 0
High Porta.3
Pause 5000
Low Porta.3
GOTO Start
-Ideas ?
mister_e
- 5th February 2007, 20:19
All fine here... Depending your osc and config fuses setting it may work or not.
Make sure you're using a 20Mhz Crystal (and a PIC16F628-20), MCLR pin set to Vdd, and try that one and post your results
@ __CONFIG _HS_OSC & _MCLRE_ON & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON
DEFINE OSC 20
PORTA=0
TRISA=0
CMCON=7
Start: TOGGLE PORTA.3
PAUSE 500
GOTO START
Config fuse setting
http://www.picbasic.co.uk/forum/showthread.php?t=543
selbstdual
- 5th February 2007, 20:35
In MPLAB having @ __CONFIG _HS_OSC & _MCLRE_ON & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON included.
Error[118] C:\PIC\XYZ.ASM 106 : Overwriting previous address contents (2007)
Error[118] C:\PIC\XYZ.ASM 106 : Overwriting previous address contents (2007)
Loaded C:\PIC\XYZ.COD.
BUILD SUCCEEDED: Mon Feb 05 21:24:52 2007
Having it removed, it compiles. I changed the conf.bits via menu according to your idea.
What happens(RA3):
Moment of Low: 0V
Moment of High: 0,71V
Other PINS
Moment of Low: 0V
Moment of High: 5V
mister_e
- 5th February 2007, 21:00
Seems you didn't have a look to the thread i suggested, but anyways...
RA.3 is a full CMOS output type, so unless
you have this pin shorted to gnd
this i/o is blow
it have to work. Try with another PIC.
selbstdual
- 5th February 2007, 21:09
I used another one and the same result.
This pin is not connected yet so outer components don't interfere.
Here's the whole code. It is a POT command replacement that fits to my circuit (RC = 420 µs). Normally Wert is replaced by Wert2's contents.
If you are not german, you should understand it anyway(Wert means value, Zaehler = counter, Gelb = yellow and Gruen = green)...
Define OSC 8
Variablen:
PORTA=0
TRISA=0
CMCON=7
TRISB = 0
PORTA = 0
;VRCON = $20
Gruene_LED VAR PORTB.5
Gelbe_LED VAR PORTB.4
ADCWert VAR WORD
Erster_Wert VAR WORD
Zweiter_Wert VAR WORD
Zaehler VAR WORD
Zahl VAR BYTE
;Interrupts
INTCON = 0
Start:
Zahl = 0
FOR Zahl = 1 TO 4
High Gelbe_LED
Pause 167
Low Gelbe_LED
Pause 307
NEXT Zahl
GOSUB Wert
Erster_Wert = ADCWert
WRITE 0, Erster_Wert.BYTE0
WRITE 1, Erster_Wert.BYTE1
Pause 2931
Zahl = 0
FOR Zahl = 1 TO 4
High Gruene_LED
Pause 167
Low Gruene_LED
Pause 307
NEXT Zahl
GOSUB Wert
Zweiter_Wert = ADCWert
WRITE 2, Zweiter_Wert.BYTE0
WRITE 3, Zweiter_Wert.BYTE1
Pause 2791
IF Erster_Wert = Zweiter_Wert THEN
High Gelbe_LED
Pause 3140
Low Gelbe_LED
Pause 2010
ENDIF
IF Erster_Wert <> Zweiter_Wert THEN
High Gruene_LED
Pause 3140
Low Gruene_LED
Pause 2010
ENDIF
GOTO Start
Wert:
HIGH PORTA.3
PAUSE 5000
LOW PORTA.3
RETURN
Wert2:
ADCWert = 0
Trisa.3 = 0
High Porta.3
Pause 243
Trisa.3 = 1 ;Vertrauscht
WHILE Porta.3 = 1
ADCWert = ADCWert + 1
WEND
Zaehler = 600 - ( (600 / 1200) * ADCWert)
Pauseus Zaehler
RETURN
END
Which thread are you referring to ?
mister_e
- 5th February 2007, 21:21
i didn't check the whole thing but i confirm that it blink PORTB.5 led, then turn on the LED on PORTA.3, then turn it off.
Your PIC i/o is dead OR there's a bad contact.
And i posted a link before in post #2 about the config fuses.
selbstdual
- 5th February 2007, 22:04
Good ideas.
i didn't check the whole thing
How can I support you in doing so ?
Your PIC i/o is dead OR there's a bad contact.
Having replaced the PIC I don't think so. I usually press it gently but firmly in the socket. Sometimes I even press when running.
And i posted a link before in post #2 about the config fuses.
Having read it fully, I will comment that. After my first impression it is just a summary of what fuses are possible. I think I am limited to the ones MPLAB offers ?! Additionally most settings are set to work in most cases so do you suggest focusing on something special for this issue ?
mister_e
- 5th February 2007, 22:54
I think I am limited to the ones MPLAB offers ?
Yes, you're limited to what's in the .INC file of your PIC.
How can I support you in doing so ?
Well if the simple TOGGLE PORTA.3 loop don't work, you have to fix it first. Trust me it's working here.
Additionally most settings are set to work in most cases so do you suggest focusing on something special for this issue ?
Well depending what you call most case.. but me, i use around 50 different PIC model and i have thousands PBP code examples, templates, projects and includes store in my computer. So... how on hearth can i remind what i'd set in all of them and how the hardware is set-up on board... I can't even predict what i'll do next time. This is why i always comment the default config fuses and set ALL of them in my code. One day if i have to modify it, i have only one place to check.
Same rules apply to the other thousand code example on other microcontroller brands and other compiler i also use.
selbstdual
- 6th February 2007, 11:59
Well if the simple TOGGLE PORTA.3 loop don't work, you have to fix it first. Trust me it's working here.
I fixed it, now it works. Let's see if the other code works aswell.
Tell me something: How can I be sure that a problem can be found in the externals ? There are so many switches in the chip - the manufacturer calls them features, I name them obstacles.
selbstdual
- 6th February 2007, 12:51
The other code doesn't work, because the capacitor doesn't discharge.
I am using a WIMA MKS 4 0,01/250-N4 capacitor, I guess that means 10nF.
The resistor is 40K.
That should mean it takes 0,00004 seconds to charge and at a maximum the same to recharge due to - er - well-intended voltage levels.
Then I am recharging it, while counting, but it doesn't stop. When short circuiting the capacitor it works, so the code is OK.
Is this cap no 10nF - cap ?
Is there anything to be changed in the code ?
ADCWert = 0
Trisa.3 = 0
High Porta.3
Pauseus 244
Trisa.3 = 1
High Gruene_LED
WHILE Porta.3 = 1
ADCWert = ADCWert + 1
WEND
Low Gruene_LED
Zaehler = 600 - ( (600 / 1200) * ADCWert) ;to keep time even
Pauseus Zaehler
RETURN
mister_e
- 6th February 2007, 16:22
maybe because your Pauseus 244 is way too high? try to remove it.
selbstdual
- 6th February 2007, 18:35
This is right. It should be 40.
But.
I found out that the circuitry itself acts as a huge capacitor compared to this one.
I replaced it with 58 pF and threw away my calculations. Now it's time
to experiment....
I am using it ratiometrically but the same value doesn't seem to exist two times.
Wert:
ADCWert = 0
Trisa.3 = 0
High Porta.3
;Pauseus 800
Trisa.3 = 1
WHILE Porta.3 = 1
ADCWert = ADCWert + 1
WEND
Trisa.3 = 0
Low Porta.3 ;To make UC = Vss
Pauseus 100 ;To make UC = Vss
RETURN
Somehow the capacitor has to have time to charge, having a too high value for Pauseus doesn't affect the measurement, it makes sure that the cap is surely charged. But here I cannot know when it's surely charged, but this must be more than zero.
selbstdual
- 6th February 2007, 21:47
I did some testing. This is the result: Max = maximum value of the resistor, InB = In Between. Pause = Pause to load the cap.
Max InB Min Min InB Max
Pause 3 46336 54273 16388 8965 48132 30980
Pauseus 5 39433 54025 11274 64777 11529 27145
It should be in the form of x² or -x². But both show strange behaviour.
Do you have an idea ?
sotoshie
- 22nd August 2014, 19:55
I fixed it, now it works. Let's see if the other code works aswell.
how did you fix it? do you still remember?
Acetronics2
- 22nd August 2014, 20:41
how did you fix it? do you still remember?
Hummmmm,
how to tell it ???
Last Activity:- 8th May 2008 12:14.
6 years after his last post ...
( and moreover ... I thought he had been banned !!! )
Alain
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.