PDA

View Full Version : 16F877 vs. 16F877A



DavyJones
- 11th April 2009, 14:02
Recently I fried my old 16F877 so I ordered a replacement from Mouser. They sent me the 16F877A because that is what I ordered. It looked like according to them the direct replacement. Admitily I didn't pay much attention to the "A" on the end. I replaced it on my board from Futurlec (http://www.futurlec.com/PIC16F877_Controller.shtml) and sent the blink.bas program down to it and I got nothing. At first I attributed that to the fact I didn't change the pic type in microstudio to a 16F877A so I did, recompiled, reprogrammed with winpic8000 and still nothing. I found this thread (http://www.picbasic.co.uk/forum/showthread.php?t=10073&highlight=16f877a) on this forum and noticed the initialization this person was using for their 16F877A was different specifically the type of oscillator. So I changed my settings to match those exactly and reprogrammed and it worked! I took a look at the data sheet to see what was the difference and how could I tell in the future which one of those oscillator types I should pick and I don't see anything directly in the data sheet that would explain why one worked over the other when the crystal and nothing else about the osc actually changed. I see were it talks about the different osc types in the datasheet but nothing reflects why one over the other with regards to the 2 different types of pics the 877 vs. the 877A. Did I miss were it tells me which setting I should pick or is this just a trial and error on the LP , XT or HS setting. I think the last one of RC would be obvious not to try unless you were actually using a resistor and capacitor. Is table 12-2 a good guidance for what setting to try within the range of the osc being used?

The crystal I am using on that futurlec board is 10mhz

Other then that my program on my pic is small I am using this to monitor a pressure transcuer on RA0 and I have a couple of small TTL relays being tripped on RA1 and RA2 and then I have one push button set up on RB0 (I've not tested the button yet on this 877A I plan to in a minute) so far everything is working find as designed and written.

Is there any other gotchas I should be aware of that I may have overlooked switching from the 877 pic to the 877A?

Thanks
David

Melanie
- 11th April 2009, 14:19
If you compare the Datasheets you'll discover the 877A has Comparators and a Voltage Reference module which can bite you if not disabled.

DavyJones
- 11th April 2009, 14:32
If you compare the Datasheets you'll discover the 877A has Comparators and a Voltage Reference module which can bite you if not disabled.

Melanie, Thanks

To shut them down correct?


adcon1=7
cmcon=7


By chance can you tell me the page/section that is in that discusses it? I just searched through my data sheet and I don't see anything specific to the 877A. I am obviously missing it.

thanks for your time
David

DavyJones
- 11th April 2009, 15:02
adcon1=7 is essentially the same as ADCON1 = 1110 right? I am not a complete loser am I?

Bruce
- 11th April 2009, 15:35
Normally you'll want to set HS_OSC for any crystal frequency over 4MHz. Some 4MHz
crystals may work with the higher drive levels, some won't.

With HS_OSC OSC2 provides a higher drive level to the crystal. With XT it's lower. The
lower drive level with your 10MHz crystal was most likely not providing enough for the
crystal to start up.

Here's an excellent set of basic PIC training modules: http://techtrain.microchip.com/x14/

Download & go through the one on oscillators.


adcon1=7 is essentially the same as ADCON1 = 1110 right?
Nope. ADCON1 = 7 is the same as ADCON1 = %00000111, which makes all analog pins
digital.

ADCON1 = %00001110 is the same as ADCON1 = 14, which leaves AN0 set to analog, and
the rest digital.

Melanie
- 11th April 2009, 15:37
I just searched through my data sheet and I don't see anything specific to the 877A.


Huh? I thought the PIC16F877A Datasheet is ENTIRELY DEVOTED to the PIC16F877A!!!

Look at the section on Comparators (section 12), look at the Voltage Reference Module (section 13).

Datasheet=Dowloaded from Microchip
Datasheet 877A < > Datasheet 877
Datasheet < > PBP Manual



adcon1=7 is essentially the same as ADCON1 = 1110 right?


Ugh.... no.

adcon1=7 is the same as ADCON1=%00000111... note the % in the statement specified BINARY, whilst the absence of anything implies DECIMAL.

ADCON1=1110 is the same as ADCON1=%10001010110... now you might find that the ADCON1 register just doesn't have that many bits...



I am not a complete loser am I?


I don't know you well enough to validate that statement! But hey, we've all been there sometime.

Byte_Butcher
- 11th April 2009, 15:44
adcon1=7 is essentially the same as ADCON1 = 1110 right? I am not a complete loser am I?


Errr..... ADCON1 = 1110 looks more like 14 to me.

How about ADCON1 = 0111

Byte_Butcher
- 11th April 2009, 15:48
Errr..... ADCON1 = 1110 looks more like 14 to me.

How about ADCON1 = 0111


Sigh... forgot my $...

How about ADCON1 = $0111

Dang, I sure wish the "edit post" button would come back....




steve

Melanie
- 11th April 2009, 15:51
$0111 = 273 = %100010001

Go into your OS Accessories Folder, call up the CALCULATOR, set the view into SCIENTIFIC MODE - it might help.

I'll get back to everyone on the Forum Editing bit.

DavyJones
- 11th April 2009, 16:03
Huh? I thought the PIC16F877A Datasheet is ENTIRELY DEVOTED to the PIC16F877A!!!


You are correct they look so similiar I am so used to looking at just the 16f877 same thing happened when I was ordering too.



Ugh.... no.

adcon1=7 is the same as ADCON1=%00000111... note the % in the statement specified BINARY, whilst the absence of anything implies DECIMAL.

ADCON1=1110 is the same as ADCON1=%10001010110... now you might find that the ADCON1 register just doesn't have that many bits...


Again my lack of posting correctly. I meant to say
ADCON1=%000001110
I abbreviated that I was trying to imply a decimal value of 111 my mistake I should have been more concise.

I want to use RA0 as my analog in thats not a problem with the 877A is it?

Melanie
- 11th April 2009, 16:14
Stop messing with ADCON1. If it worked for the 877 it'll work for the 'A'.

Just deal with CMCON and CVRCON.

mister_e
- 11th April 2009, 16:54
You might have some issue with winpic software. If I remember correctly, there's a slight difference in the programming between 16F877 and 16F877A.

Make sure winpic support the A version or you select it before programming your PIC, and try to do a programming check.

DavyJones
- 11th April 2009, 18:22
Stop messing with ADCON1. If it worked for the 877 it'll work for the 'A'.

Just deal with CMCON and CVRCON.

Will do I just wanted to double check myself making sure I had that set correctly which it's apparent I do.

By default it looks like according to the 16F877A (I just downloaded the correct data sheet) that CVCRON by default is off so I need'nt worry about that correct?




You might have some issue with winpic software. If I remember correctly, there's a slight difference in the programming between 16F877 and 16F877A.

Make sure winpic support the A version or you select it before programming your PIC, and try to do a programming check.


I checked to make sure both microstudio and winpic have the 877A listed and made sure they were selected when I compiled and uploaded. FYI. WinPic auto detected the 877A and set itself.

Thanks all

David