PDA

View Full Version : 16F676 Please explain this problem...



Jayhovah
- 9th May 2008, 04:02
Here is some very simple example code that exhibits a problem I am unable to explain.
The following code WORKS. Following it, I will show something that does NOT WORK.

@ DEVICE pic16F676, INTRC_OSC_NOCLKOUT
@ DEVICE pic16F676, WDT_OFF
@ DEVICE pic16F676, PWRT_OFF
@ DEVICE pic16F676, MCLR_OFF
CMCON = %00000111
ANSEL = %00000000
TRISC = %000000

PAUSE 1

Main:
HIGH PORTC.0
HIGH PORTC.1
HIGH PORTC.2
HIGH PORTC.3
HIGH PORTC.4
HIGH PORTC.5
PAUSE 500
LOW PORTC.0
LOW PORTC.1
LOW PORTC.2
LOW PORTC.3
LOW PORTC.4
LOW PORTC.5
PAUSE 500
GOTO MAIN

Now, If I replace the Main section with:

Main:
PORTC = %111111
PAUSE 500
PORTC = %000000
PAUSE 500
GOTO MAIN

It hiccups. Will blink once or twice.. maybe several times.. but will hiccup and stop and start very intermittently. What am I doing incorrectly here?

paul borgmeier
- 9th May 2008, 04:42
1 - What are you using for the power supply?

2 - Do you have decoupling cap close to VDD (to GND)?

Acetronics2
- 9th May 2008, 08:19
Hi,

adding to Paul's ( good !!! ) questions ...

What kind of load do you place on your outputs ( LEDs Ok, I wonder ! , but current = ? series resistor = ? )

What kind of supply do yo have provided ??? ( a 6 LR 61 batt . ... joking ! )

Alain

Jayhovah
- 9th May 2008, 21:30
Ahh.. I rearranged the board and forgot to put the cap back.. i gotta go find that -- although that does make sense.

I am using a 9V AC adapter with a 5V Vreg for the positive supply...

I am running LED's but they are buffered from the PIC's outputs with BJT's.

EDIT: putting the cap back solved the problem... argh! sometimes I feel so foolish =)
Thanks guys..