Newbie - Can't Swith LEDs

Started by Andy Laurence March 13, 2004
I've just started in the world of PICs. I have an Ad-Teknik Elvis
programmer that does smart cards, and 18-pin PICs. I also have the
associated MP6 programming software. I've programmed a PIC16F84A
(http://www.andylaurence.co.uk/TEST.HEX or
http://www.andylaurence.co.uk/TEST.ASM or
http://www.andylaurence.co.uk/test.bas), and this should pulse A0-3
and B0-7 high every 100ms. So, I should see 5 flashes a second from
the LEDs connected to the ports. I've built the circuit on a
breadboard, and applied 5vdc. There is a single LED connected to
RB0, but it does not light.

I've checked with a multimeter, and everything appears correct,
except there is no pulse to the pin. As this is just a test (I'm
building myself up slowly), I'm not sure whether it's my software or
the circuit I've built. The program is so simple, I can't see how it
could be wrong, but the same for the circuit. Any help/guidance
appreciated. If you're interested in my longer term aims, take a
peek at http://ha.andylaurence.co.uk/lighting/index.shtml

Cheers,
Andy
--
http://www.andylaurence.co.uk
http://ha.andylaurence.co.uk



Have you included an oscilator-circuit or a resonator
on your breadboard? The '84 doesn't have an internal
one, it needs an external 4 Mhz oscilator to run.

Kees

--- Andy Laurence <> wrote:
> I've just started in the world of PICs. I have an
> Ad-Teknik Elvis
> programmer that does smart cards, and 18-pin PICs.
> I also have the
> associated MP6 programming software. I've
> programmed a PIC16F84A
> (http://www.andylaurence.co.uk/TEST.HEX or
> http://www.andylaurence.co.uk/TEST.ASM or
> http://www.andylaurence.co.uk/test.bas), and this
> should pulse A0-3
> and B0-7 high every 100ms. So, I should see 5
> flashes a second from
> the LEDs connected to the ports. I've built the
> circuit on a
> breadboard, and applied 5vdc. There is a single LED
> connected to
> RB0, but it does not light.
>
> I've checked with a multimeter, and everything
> appears correct,
> except there is no pulse to the pin. As this is
> just a test (I'm
> building myself up slowly), I'm not sure whether
> it's my software or
> the circuit I've built. The program is so simple, I
> can't see how it
> could be wrong, but the same for the circuit. Any
> help/guidance
> appreciated. If you're interested in my longer term
> aims, take a
> peek at
> http://ha.andylaurence.co.uk/lighting/index.shtml
>
> Cheers,
> Andy
> --
> http://www.andylaurence.co.uk
> http://ha.andylaurence.co.uk >


__________________________________





Kees Stenekes wrote:
> Have you included an oscilator-circuit or a resonator
> on your breadboard? The '84 doesn't have an internal
> one, it needs an external 4 Mhz oscilator to run.

I copied a circuit off the 'net. Clearly the circuit was wrong as it
doesn't have any capacitors tying the resonator to earth. I'm off to get
some suitable caps in the morning. Thanks for the pointer - spot on
(assuming this is the cause).

Cheers,
Andy
--
http://www.andylaurence.co.uk
http://ha.andylaurence.co.uk



Or he could use an external RC tied to OSC1 if precise timing isn't
important.

-Mike --- In , Kees Stenekes <knalkeez@y...> wrote:
> Have you included an oscilator-circuit or a resonator
> on your breadboard? The '84 doesn't have an internal
> one, it needs an external 4 Mhz oscilator to run.
>
> Kees


At 12:59 PM 3/13/2004, Andy Laurence wrote:
>Kees Stenekes wrote:
> > Have you included an oscilator-circuit or a resonator
> > on your breadboard? The '84 doesn't have an internal
> > one, it needs an external 4 Mhz oscilator to run.
>
>I copied a circuit off the 'net. Clearly the circuit was wrong as it
>doesn't have any capacitors tying the resonator to earth. I'm off to get
>some suitable caps in the morning. Thanks for the pointer - spot on
>(assuming this is the cause).

Why not try using external RC mode for now - look up the connections in the
data sheet. Its not very accurate but will at least give you the
confidence that everything is working properly. Just 2 components: 1
resistor & 1 capacitor. Be sure to set the configuration fuses for EXTRC mode.

Or - make a couple of small capacitors from twisted insulated wire. Take 2
pcs of thin insulated solid wire about 1.5" long and twist together
tightly. Solder one end of the twisted pair where the cap is supposed to
be, make sure the free end is not shorted. You should have 20 or more
twists in the wire - this will be somewhere around 20 to 30 pF. I use
solid wire from large telephone cables (25 pair or more) - this stuff is
just right for bread-boarding and general hook-up and works well for this
application.

I've even used 1 bare wire twisted with an insulated wire - the bare wire
is ground, the insulated wire goes to the crystal. Its best to solder the
wires to the board before twisting in this case - soldering temperature
might cause the insulation to melt and cause a short. Just solder the 2
wires into the space where the caps are supposed to be, then twist into a
pigtail. Again, be sure the wires don't short together.

The idea is to not let the lack of a couple of small caps stop you from
experimenting.

dwayne

--
Dwayne Reid <>
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax

Celebrating 20 years of Engineering Innovation (1984 - 2004)
.-. .-. .-. .-. .-. .-. .-. .-. .-. .-
`-' `-' `-' `-' `-' `-' `-' `-' `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.



Cool tip about using twisted wires for caps. I never would have
thought of that.

Mike --- In , Dwayne Reid <dwayner@p...> wrote:
> At 12:59 PM 3/13/2004, Andy Laurence wrote:
> Or - make a couple of small capacitors from twisted insulated
wire. Take 2
> pcs of thin insulated solid wire about 1.5" long and twist together
> tightly. Solder one end of the twisted pair where the cap is
supposed to
> be, make sure the free end is not shorted. You should have 20 or
more
> twists in the wire - this will be somewhere around 20 to 30 pF. I
use
> solid wire from large telephone cables (25 pair or more) - this
stuff is
> just right for bread-boarding and general hook-up and works well
for this
> application.
>
> I've even used 1 bare wire twisted with an insulated wire - the
bare wire
> is ground, the insulated wire goes to the crystal. Its best to
solder the
> wires to the board before twisting in this case - soldering
temperature
> might cause the insulation to melt and cause a short. Just solder
the 2
> wires into the space where the caps are supposed to be, then twist
into a
> pigtail. Again, be sure the wires don't short together.
>
> The idea is to not let the lack of a couple of small caps stop you
from
> experimenting.
>
> dwayne


Dwayne Reid wrote:
> At 12:59 PM 3/13/2004, Andy Laurence wrote:
>> Kees Stenekes wrote:
>>> Have you included an oscilator-circuit or a resonator
>>> on your breadboard? The '84 doesn't have an internal
>>> one, it needs an external 4 Mhz oscilator to run.
>>
>> I copied a circuit off the 'net. Clearly the circuit was wrong as it
>> doesn't have any capacitors tying the resonator to earth. I'm off
>> to get some suitable caps in the morning. Thanks for the pointer -
>> spot on (assuming this is the cause).
>
> Why not try using external RC mode for now - look up the connections
> in the data sheet. Its not very accurate but will at least give you
> the
> confidence that everything is working properly. Just 2 components: 1
> resistor & 1 capacitor. Be sure to set the configuration fuses for
> EXTRC mode.
>
> Or - make a couple of small capacitors from twisted insulated wire.

Genius! Never thought of that. I now have my proper caps though, so I've
gone with the known element. However, it still doesn't work! I've copied a
sample program and circuit from the PICBasic manual, and still nothing. I
get this feeling my programmer isn't programming the chip properly.

Andy (quickly balding)
--
http://ha.andylaurence.co.uk
http://www.andylaurence.co.uk



--- In , "Andy Laurence" <andy@a...> wrote:
...
> Genius! Never thought of that. I now have my proper caps though,
so I've
> gone with the known element. However, it still doesn't work! I've
copied a
> sample program and circuit from the PICBasic manual, and still
nothing. I
> get this feeling my programmer isn't programming the chip properly.

before all your hair falls out, try just lighting (not flashing) the
led. turn it on, leave it on.

do a verify with your programmer, it should be able to read the
program back and determine if its in F84.

Also, I tried importing your .hex file into mplab but couldn't
disassemble it. I can disassemble other .hex files so there might be
something wrong with it. It seems a bit small for what I expect from
a compiled basic file.

finally, why an F84? That is an ancient chip. I'd at least look at
the F628, F88 or F819. cheaper, faster and more features.

phil


Phil wrote:
> --- In , "Andy Laurence" <andy@a...> wrote:
> ...
>> Genius! Never thought of that. I now have my proper caps though,
> so I've
>> gone with the known element. However, it still doesn't work! I've
>> copied a sample program and circuit from the PICBasic manual, and
>> still
> nothing. I
>> get this feeling my programmer isn't programming the chip properly.
>
> before all your hair falls out, try just lighting (not flashing) the
> led. turn it on, leave it on.

Will do.

> do a verify with your programmer, it should be able to read the
> program back and determine if its in F84.

The software I use verifies it when it writes it. It verifys OK.

> Also, I tried importing your .hex file into mplab but couldn't
> disassemble it. I can disassemble other .hex files so there might be
> something wrong with it. It seems a bit small for what I expect from
> a compiled basic file.

That could be it. I'm using the assembler bundled with PIC Basic Pro.
Perhaps I shall try another. Can you recommend one?

> finally, why an F84? That is an ancient chip. I'd at least look at
> the F628, F88 or F819. cheaper, faster and more features.

Firstly, I was given a bundle of them, and secondl;y the test circuit and
program in the PBP manual shows an F84. I plan to migrate to a 16C505 after
initial testing.

Cheers,
Andy
--
http://ha.andylaurence.co.uk
http://www.andylaurence.co.uk



--- In , "Andy Laurence" <andy@a...> wrote:
> Phil wrote:
> > --- In , "Andy Laurence" <andy@a...> wrote:
> > Also, I tried importing your .hex file into mplab but couldn't
> > disassemble it. I can disassemble other .hex files so there
might be
> > something wrong with it. It seems a bit small for what I expect
from
> > a compiled basic file.
>
> That could be it. I'm using the assembler bundled with PIC Basic
Pro.
> Perhaps I shall try another. Can you recommend one?

ah, test.asm is the output from the basic compiler? It doesn't look
like microchip asm, more like some kind of interpreted code. The
basic run time should be included (I think that's what the
PBPPIC14.LIB is about). I doubt that any other assembler would
swallow it but others of the BASIC persuasion will know better than I.

Have you selected the correct processor for your Basic program?
PBPPIC14 could be for the PIC14 line of processors and you have a
PIC16 (midrange) processor but that's just a wild guess...

do try reading back the PIC program from flash to see if it got there
but I suspect your programmer is OK.

Phil