PDA

View Full Version : trouble with my 16f84a



cavity creep
- 28th November 2008, 04:23
Hello, I've gotten to dabbling with some old pics that I've had stashed away this holiday, and I am experiencing something strange with one of the ports.I'll
try to make the scenario as clear as possible.

I'm going through the old "Pic Robotics" book by John Iovine. I haven't tinkered with PIC stuff in a year or two so I figured it would be a good idea to test them with the simple "wink" program using 2 LEDS. I won't post the actual tech drawing here as I'm sure most of you are familiar with it. In any case, only one LED is blinking(rb0).The other(rb1) isn't doing anything.

I've read the PICs and went over the circuit several times and still can't figure out whats going on.I've also programmed two different pics, but I get the same result each time.I'm using the EPIC Plus if that helps at all. Does anyone have any idea what I could be doing wrong?

Here's the code in case someone sees something I'm missing.Thanks for looking!

Shawn

start:
high portb.0
low portb.1
pause 500
low portb.0
high portb.1
pause 500
goto start

mackrackit
- 28th November 2008, 05:08
Have you tried a different pin another LED?
I do not see anything wrong with the part of your code you have posted.
How do you have TRISB set?
If you post the whole code it would help.

Acetronics2
- 28th November 2008, 09:18
Hi,

What about your oscillator settings ???

Alain

cavity creep
- 28th November 2008, 19:59
Have you tried a different pin another LED?
I do not see anything wrong with the part of your code you have posted.
How do you have TRISB set?
If you post the whole code it would help.



That's actually the entirety of the code(although I set TRISB to 0 anyway).Not much to it.Also the oscillator setting is set for crystal.(xt).I tried it with a different pin and came up with the same problem.When I took the LED away from pin 6(rb0) however, the other lit up.

I'm wondering if it may be a power supply problem.I've currently got a 7805 voltage regulator to step down a 9 volt battery, but I'm wondering if the battery is too low.

The battery rates at 7.97 volts according to my meter.Could this be too low after the 7805 is connected?

Shawn

mackrackit
- 28th November 2008, 21:22
PicBasic will defualt to 4MHz. So if your crystal is running at 4 then you should be OK.
I think it is a good idea to leave nothing to chance and define it at all times.


DEFINE OSC 8 'Speed of OSC

I also think it is better to set each bit of TRIS?.
0 = Outpuit
1 = Input


TRISB = $00000000

While you are brushing up on things, these two threads are a must read.
Even if you do not set the fuses in code space this will give you a better understanding of how it all works.
http://www.picbasic.co.uk/forum/showthread.php?t=543
The chip you are using has analog.
http://www.picbasic.co.uk/forum/showthread.php?t=561

Power supply.
9 volt battery is to wimpy. Better off to use a pack of AA if you want to run off batteries.
Check the data sheet of the 7805 to find minimum voltage. At least 2 volt higher than out put.

cavity creep
- 29th November 2008, 05:02
I looked at the melabs datasheet and it says that I do not have analog pins. I'm not go to dismiss the possibility that I misunderstood though:p
I also looked at the info on the configuration fuses, and while it's pretty cool to be able have access to those, I'm positive I would just be digging my self a larger and more frustrating hole.
Any other ideas what could be the problem? I'm stumped.

mackrackit
- 29th November 2008, 05:14
I looked at the melabs datasheet and it says that I do not have analog pins. I'm not go to dismiss the possibility that I misunderstood though:p
My mistake, dirty glasses :o

I would say try a better power supply. Is there a way to pull power from the EPIC?

cavity creep
- 29th November 2008, 16:12
Not that I know of.At least I don't think so. I tried another power supply(some aa's) , but to no avail. I'm wondering if the programmer is not setting the pin high as intstructed. Could this be a problem with the EPIC or perhaps a bad cable? Is there any way to test the programmer(or the chips for that matter) for a defect?
If anyone needs me, I'll be staring blankly at this breadboard with with contempt.:confused:
Thanks,
Shawn

Acetronics2
- 29th November 2008, 16:42
Hi, Shawn

Did you also think to tie the MCLR pin to V+ ???

some details about Hardware are not too much nor ... YOUR scheme will be perfect.

...

Alain

cavity creep
- 29th November 2008, 17:18
Hi Alain. Yes it's definitely tied to positive.I'm actually getting power throughout the chip, only little or no power to the portb pins for some reason.
I was wondering if this was an intermittent kind of problem initially, because I would get at least one LED to blink and then none at all.But two different PICs with the same problem? Also different power supplies seem to be ineffective.

As far as the circuit goes, I can't find a diagram right now to post(about to head out for the afternoon), but I'll try to give you a breakdown.

pin 4= POSITIVE with 47k resistor

pin 5= NEGATIVE

PIN 6 AND 7= LEDs with 470 ohm resistors(and yes, the polarity is correct:))

pin 14 =positive

pin 15 and 16 =crystal with two 22 pf caps attached to ground

If you see something I've done wrong, please feel free to let me know.Frankly I'm baffled.

Bruce
- 29th November 2008, 17:37
Does this work?


P_Val VAR BYTE
TRISB=0

start:
P_VAL=2 ' RB0=0, RB1=1
portb = P_VAL
pause 500
P_VAL=1 ' RB0=1, RB1=0
portb = P_VAL
pause 500
goto start

aratti
- 29th November 2008, 22:44
pin 4= POSITIVE with 47k resistor

pin 5= NEGATIVE

PIN 6 AND 7= LEDs with 470 ohm resistors(and yes, the polarity is correct)

pin 14 =positive

pin 15 and 16 =crystal with two 22 pf caps attached to ground


I have never seen a 47K resistor on reset pin! Tray a 10K

Pin 5 negative? , surely you mean ground !

crystal with two 22 pf caps attached to ground (4 MHz?)

In your program modify pause to 5000, then with a DVM measure port pins. If you see both pins turning on & off then you have a bad ground or a bad resistor or a bad led connected to the led that doesn't work. On the other hand if you don't see the +5 volts ont both pins than you have a bad pic.

Appart from that I don't see reason for your leds not blinking.

Al.

Acetronics2
- 30th November 2008, 10:05
Hi, Shawn

Could you post your HEX code ( not Basic ! ) ???

I think it's the only way to verify what you put into your Pic ... ( Mr de la Pallice dixit )

Alain

cavity creep
- 30th November 2008, 17:49
I have never seen a 47K resistor on reset pin! Tray a 10K

Pin 5 negative? , surely you mean ground !

crystal with two 22 pf caps attached to ground (4 MHz?)

In your program modify pause to 5000, then with a DVM measure port pins. If you see both pins turning on & off then you have a bad ground or a bad resistor or a bad led connected to the led that doesn't work. On the other hand if you don't see the +5 volts ont both pins than you have a bad pic.

Appart from that I don't see reason for your leds not blinking.

Al.


For this particular PIC at least , it seems to be the norm to use a 47k resistor. The crystal is 4 mhz. And yes,I meant ground:P
I tried what you recommended , and checked the pins.I am getting a very tiny voltage value ( the last was 35.6 mV.).I've got a feeling I have a couple of bad chips, unless someone can think of another reason for this:(

Alain I'm going to post the Hex listing here of the most recent wink program.Thanks for taking a look at it.

:1000000028288F018E00FF308E07031C8F07031CEA
:10001000232803308D00DF300F2003288D01E83EB8
:100020008C008D09FC30031C18288C070318152838
:100030008C0764008D0F15280C181E288C1C222894
:1000400000002228080083130313831264000800B1
:1000500006148316061083128610831686108312E8
:1000600013308F008830022006108316061083128A
:10007000861483168610831213308F008830022076
:060080002828630041285E
:02400E00FD3F74
:00000001FF

mackrackit
- 30th November 2008, 18:17
For this particular PIC at least , it seems to be the norm to use a 47k resistor. ???
Do you mean 4.7K

cavity creep
- 30th November 2008, 18:19
Yes I did.Apologies for the typos.

mackrackit
- 30th November 2008, 18:30
Yes I did.Apologies for the typos.

Darn, that probably would have been the problem.

I do not have an 84A to test your HEX with, but I can say the fuses are correct.
I do not think it will make a difference, but you may try setting the WatchDogTimer to OFF??

cavity creep
- 30th November 2008, 18:44
Would you believe that did the trick?????:D

Thanks you so much! Can you give a little insight into what exactly is going on with the timers?I'm certain I'll run into this again.

Thanks again to everybody for their insight:)

Shawn

mackrackit
- 30th November 2008, 18:54
The data sheet says it best. If not, let us know.


6.10 Watchdog Timer (WDT)
The Watchdog Timer is a free running On-Chip RC
Oscillator which does not require any external
components. This RC oscillator is separate from the
RC oscillator of the OSC1/CLKIN pin. That means that
the WDT will run even if the clock on the OSC1/CLKIN
and OSC2/CLKOUT pins of the device has been
stopped, for example, by execution of a SLEEP
instruction. During normal operation, a WDT time-out
generates a device RESET. If the device is in SLEEP
mode, a WDT wake-up causes the device to wake-up
and continue with normal operation. The WDT can be
permanently disabled by programming configuration bit
WDTE as a '0' (Section 6.1).
6.10.1 WDT PERIOD
The WDT has a nominal time-out period of 18 ms, (with
no prescaler). The time-out periods vary with
temperature, VDD and process variations from part to
part (see DC specs). If longer time-out periods are
desired, a prescaler with a division ratio of up to 1:128
can be assigned to the WDT under software control by
writing to the OPTION_REG register. Thus, time-out
periods up to 2.3 seconds can be realized.
The CLRWDT and SLEEP instructions clear the WDT
and the postscaler (if assigned to the WDT) and prevent
it from timing out and generating a device
RESETcondition.
The TO bit in the STATUS register will be cleared upon
a WDT time-out.

cavity creep
- 30th November 2008, 19:35
Well here's the strange thing.Shutting off the watchdog timer works quite well on one PIC.It functions as it is supposed to.However, I tried the exact same thing in the exact same circuit with the other pic, and it doesn't work. Same old problem. Also the book I've been referencing states to set the watchdog and power up timers on.
Any thoughts?

mackrackit
- 30th November 2008, 20:14
Well here's the strange thing.Shutting off the watchdog timer works quite well on one PIC.It functions as it is supposed to.However, I tried the exact same thing in the exact same circuit with the other pic, and it doesn't work. Same old problem. Also the book I've been referencing states to set the watchdog and power up timers on.
Any thoughts?

Just guessing...as usual.

Try reading the PIC and see if that hex matches the hex generated by the assembler. The config part might not be getting programed correctly.

If they are not the same.

Erase all but the chips ID if the EPIC has that setting. Then write to the chip program memory and config settings.

cavity creep
- 30th November 2008, 22:00
Nope.They look the same.

Acetronics2
- 1st December 2008, 09:03
Hi,

Works fine, as written ...

Hardware problem ( or config ) ... then !!!

Alain

Bruce
- 1st December 2008, 17:25
Have you tried the code example I posted above?

cavity creep
- 2nd December 2008, 04:05
Hi,

Works fine, as written ...

Hardware problem ( or config ) ... then !!!

Alain

I'm going to have to agree with you I think.I suppose I have one good PIC and one bad, but I would think I would have difficulty reading from the ports of aa bad one, or at the very least the programmer would fail to recognize it.Maybe I'm asking for too much.

Bruce, I haven't tried your code yet.I'm afraid your suggestion got buried in the conversation.I think I'll give it a try and post the results later if I have any success.

Thanks for everyone for helping me figure this out.I'm sure I'll have many more questions as I go:D

Acetronics2
- 2nd December 2008, 08:47
Hi,

I'd suggest you to try to place 4.7k and 22 pf as the external RC Clock components ... and give a try like that ...

no risk !

Will tell if CONFIG Word is transmitted by the programmer ...

Just one step further.

Alain

cavity creep
- 2nd December 2008, 23:33
Hi,

I'd suggest you to try to place 4.7k and 22 pf as the external RC Clock components ... and give a try like that ...

no risk !

Will tell if CONFIG Word is transmitted by the programmer ...

Just one step further.

Alain

Do you mean to use a 4.7 k resistor instead of the crystal and set the oscillator at RC?