PIC 16F877A problems...

Started by shet...@gmail.com January 11, 2008
I'm trying to get PIC 16F877A to work with a 20Mhz crystal. I'm a beginner with PIC, tho i have decent exp with other controllers.

i'm having problems trying to get it to work. If i understand correctly, the crystal needs to be connected between osc1 and osc2 pins with caps to ground. I'm using hi-tech's PICC and tide to compile and assemble the program, which i then burn to the chip. the program i'm trying to run is nothin much, jus tryin to light 8 leds on portb(PORTB = 0b10101010) and toggle their state at every timer interrupt. but all i get is a 3.68V on all the portB pins. also i tried checking the voltage at the osc1 and osc2 pins, i have .9V on thm.
I'v read in one of the other posts tht the free samples from microchip sometimes run only up2 4Mhz, and we shud check the part no. well, the sample tht i'v got is

"PIC16F877A
07312FG"

does this mean tht the sample will only work upto 12mhz?? or is there somethin else i might be rong at... any suggestions???
First of all, welcome to PICs!

Your problem could be anywhere. First, make sure that you have the
correct processor declared in both the IDE's menu and in the code
itself. Be sure that you have the 'A' at the end of 16F877A as the
processor is different from the 16F877. Second, use a RC osc. since
you seem to be doing a simple task. If you have a function generator
just hook that up to the ocs1 port. That has done a great job in the
past for me. Personally i like to use prepackaged resonators due to
the smaller profile and less likelyhood of me making a mistake.
Finally, the best thing to do in general is program in assembly. That
way you know what is really going on. Your third party complier may be
the worst thing against you. Who knows what it is doing back there. At
the very least use MPLAB, it is free and i think there is a C
enviromnent in it.
Make sure you are running this at 5V, i know others are only 3.6V. And
be sure that you have the MCLR tied to the high potential.
Let me know how it goes.

Good luck,

James
--- In p..., shethpratik@... wrote:
>
> I'm trying to get PIC 16F877A to work with a 20Mhz crystal. I'm a
beginner with PIC, tho i have decent exp with other controllers.
>
> i'm having problems trying to get it to work. If i understand
correctly, the crystal needs to be connected between osc1 and osc2
pins with caps to ground. I'm using hi-tech's PICC and tide to compile
and assemble the program, which i then burn to the chip. the program
i'm trying to run is nothin much, jus tryin to light 8 leds on
portb(PORTB = 0b10101010) and toggle their state at every timer
interrupt. but all i get is a 3.68V on all the portB pins. also i
tried checking the voltage at the osc1 and osc2 pins, i have .9V on thm.
> I'v read in one of the other posts tht the free samples from
microchip sometimes run only up2 4Mhz, and we shud check the part no.
well, the sample tht i'v got is
>
> "PIC16F877A
> 07312FG"
>
> does this mean tht the sample will only work upto 12mhz?? or is
there somethin else i might be rong at... any suggestions???
>
Hi,

Worth checking the datasheet for full details, but I think that all variants
of the 16F877A can run at 20Mhz. If you look at table 14.2 on page 146 it
gives a table on the recommended capacitors to use. I've used 22pf with a
20 Mhz Xtal and found the chip to be most stable, but 33pf will give a very
stable set up, but the start up time is also increased.

The other thing to watch is that you have the configuration set to HS, that
the 5v is regulated and stable (a 7805 reg and a couple of capacitors should
do the job) and that you tie MCLR to the +V supply via a 10K resistor.

Maybe its worth trying a simple delay loop to flash the LEDs first and then
look at using the interrupt option ?

Malcolm

--- In p... ,
shethpratik@... wrote:
>
> I'm trying to get PIC 16F877A to work with a 20Mhz crystal. I'm a
beginner with PIC, tho i have decent exp with other controllers.
>
> i'm having problems trying to get it to work. If i understand
correctly, the crystal needs to be connected between osc1 and osc2
pins with caps to ground. I'm using hi-tech's PICC and tide to compile
and assemble the program, which i then burn to the chip. the program
i'm trying to run is nothin much, jus tryin to light 8 leds on
portb(PORTB = 0b10101010) and toggle their state at every timer
interrupt. but all i get is a 3.68V on all the portB pins. also i
tried checking the voltage at the osc1 and osc2 pins, i have .9V on thm.
> I'v read in one of the other posts tht the free samples from
microchip sometimes run only up2 4Mhz, and we shud check the part no.
well, the sample tht i'v got is
>
> "PIC16F877A
> 07312FG"
>
> does this mean tht the sample will only work upto 12mhz?? or is
there somethin else i might be rong at... any suggestions???
>

__________ NOD32 2785 (20080111) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com
> I'm trying to get PIC 16F877A to work with a 20Mhz crystal. I'm a
> beginner with PIC, tho i have decent exp with other controllers.

Try one thing at a time. There are blink-a-led examples at my site at
http://www.voti.nl/blink, try the one for the 877(A) to check that your
hardware is OK.

Next try to blink one LED using your compiler, but use busy delays, not
interrupts. Once you have that working you might try interrupts.

AFAIK is no -4 version of the 877A.

In my experience Microchip samples you exactly what you ask for, so you
will get a -4 version (if such a version exists for the chip you sample)
*only* when you aks for a -4.

Wouter van Ooijen

-- -------
Van Ooijen Technische Informatica: www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: www.voti.nl/hvu