PDA

View Full Version : Why does the clock stop?



Russ Kincaid
- 27th May 2006, 02:33
I am using the internal oscillator. At power up, the PIC goes right to the freq loop, the IF - THEN statements are ineffective and portb.5 does not go low. When I bring portb.5 low, nothing happens but when portb.5 goes high, the clock stops and the power is low. Making portb.5 low again will start the clock but I don't want it to work that way.

REM THIS IS JUST TO SEE IF I CAN MAKE ANYTHING WORK
TRISA = %00010000 'PORT A ALL OUTPUTS, EXCEPT MCLR IS INPUT
TRISB = %00111111 ' PORT B ALL INPUTS EXCEPT 6 & 7 OUTPUT
OPTION_REG = %01111111 ' ENABLE WEAK PULLUP ON PORT B
START:
IF PORTB.5 = 0 THEN POO
IF PORTB.5 = 1 THEN START


POO:
LOW PORTB.5
FREQ:
TOGGLE PORTB.7
PAUSEUS 700
GOTO FREQ
END

BigWumpus
- 27th May 2006, 14:06
Your routine has some bugs:

The If/Then-Part is only used at the very first counts of the PIC.
If PortB.5 is low, it goes to POO, lows PortB.5 (switching from input to output) and circles in the FREQ-Part.
If PortB.5 is high, it circles inside the START-part (does nothing to the outside) and and waits for PortB.5 to go down.


What do you really want to get ?

Acetronics2
- 27th May 2006, 15:32
CMCON = 7 ... it's a 16F627 !!!

Alain

mister_e
- 27th May 2006, 15:43
Alain, keep eyes wide open, our friend don't even use the PORTA. As BigWumpus said, is much a matter of Using LOW statement on the same pin used for the initial test.

Maybe LOW PORTB.6 could be the answer.

Acetronics2
- 27th May 2006, 15:54
Heuuuuu

What about MCLR ???

" TRISA = %00010000 'PORT A ALL OUTPUTS, EXCEPT MCLR IS INPUT "

You'll laugh ... I run his program on my test board !!! ... and it works ... in real life !!!

see : http://www.picbasic.co.uk/forum/showthread.php?t=3944

Alain

Russ Kincaid
- 28th May 2006, 01:38
So, why does it run on your test board and not on mine?
And, I don't understand CIMCON = 7, it is a register so shouldn't it be
CIMCON = %0001001 ? And what does that do?

My circuit is this: except the switch only goes to ground since I enabled the internal pullups.
Hmmm, I just noticed that my schematic is not up to date: the inputs are RB4 & RB5, the outputs are RB6 & RB7.

BigWumpus
- 28th May 2006, 08:33
So, why does it run on your test board and not on mine?
And, I don't understand CIMCON = 7, it is a register so shouldn't it be
CIMCON = %0001001 ? And what does that do?

My circuit is this: except the switch only goes to ground since I enabled the internal pullups.
Hmmm, I just noticed that my schematic is not up to date: the inputs are RB4 & RB5, the outputs are RB6 & RB7.

1. I see no 0,1uF-ceramic-condensator near the VSS/VDD-pins.

2. I see no bits to turn on the pull-ups inside your program.

3. Read the part on the comperators and the CMCON-register in the manual, tell use what you're CIMCON-register is.

4. Using RB4 ? You has disabled LVP in your fuses ?


...I'm dreaming of mr. eng4444 ! (he's back!!!! ;-) )
Give us more informations, if you want to get some help. Just list your program here!

Acetronics2
- 28th May 2006, 09:36
Hi,Russ

If you use RB2 and RB3 as switches ... and test the led outputs instead of the switches ... There's no chance it could work properly.

I know that doesn't solve the oscillator question ... but ...

Alain

PS : try to work on ONE scheme at a time ... it will be easier for us to follow you !!!

Russ Kincaid
- 29th May 2006, 15:36
Bigwumpus gave me the clue: I disabled low voltage programming and it works! Thanks to all.

Russ