![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Coder Guest
|
PIC16F877A doesnt program via ICD 2.. ANY ideas ? |
Posted: Sun Jun 13, 2004 2:40 pm |
|
|
Hi,
ive been trying to migrate gracefully from a 16F876 to a 16F876A but unfortunatly it doesnt look like its working.
then i tried using a PIC16877A (40 pin DIP) since i thought my small package of the 16F876A (TQFN) was the problem. but that doesnt work either.
the code works perfectly on a PIC16F876 but not in any of the A variants(even though i select the correct A variant from the MPLAB IDE CONFIGURE>DEVICE SELECT). it doesnt even switch a port ON .
ive checked all the connections , clocks, bypass caps, the new MCLR* pull up with the cap and without, etc. but still no luck
im using MPLAB IDE 6.53 and ive even tried it on 6.1.
ccs pcw 3.168 which has the header file for the 16F877A but it doesnt show up as a device which i can select via tools>device selector
the programmer im using is the ICD 2 , and i tried to program it even with a PICSTART PLUS. with no luck.
so at this point im assuming the problem is with the pcw compiler. or am i wrong?
can someone please give me some feed back on this as ive tried everything i can think of. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 13, 2004 3:44 pm |
|
|
Post a small but complete test program. (including all #fuse statements,
#use delay statements, etc). I'll compile it and look at the problem. |
|
![](templates/subSilver/images/spacer.gif) |
Coder Guest
|
small test prog |
Posted: Sun Jun 13, 2004 5:29 pm |
|
|
The following code will simply turn on and off A1 and A2.
Code: |
#include <16F877A.h>
#use delay(clock=20000000)
#fuses XT, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT
void main()
{
while(true){
output_high(PIN_A1);
output_low(PIN_A2);
delay_ms(1000);
output_low(PIN_A1);
output_high(PIN_A2);
delay_ms(1000);
}
}
|
i hope this is what you were reffering to as a small but complete test prog.
i didnt think i should post the program that im trying to migrate to the "A" family, since its a few hundred lines of code.
thanks alot |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 13, 2004 6:08 pm |
|
|
Quote: | #include <16F877A.h>
#use delay(clock=20000000)
#fuses XT, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT |
The first thing you should do is change the Oscillator drive level
to HS, since you're using a 20 MHz crystal. Example:
#fuses HS, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT |
|
![](templates/subSilver/images/spacer.gif) |
Coder Guest
|
|
Posted: Sun Jun 13, 2004 6:17 pm |
|
|
your quite right, but I've tried that many times prior to the posting without any luck.
although it worked in XT mode with a 20Mhz xtal on the 16F876. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Jun 13, 2004 7:12 pm |
|
|
Well, I looked at the code in the .LST file, and I only see one thing
that's wrong. I think CCS intended to turn off the Comparator
module by writing 0x07 to it. But they're using the wrong register
address. They're writing to ADCON0. They don't even have to
turn off the comparators, because according to the data sheet,
they're turned off by default, upon power-up.
Code: |
CCS PCM C Compiler, Version 3.168
0000 00304 .................... void main()
0000 00305 .................... {
0017 0184 00306 CLRF 04
0018 301F 00307 MOVLW 1F
0019 0583 00308 ANDWF 03,F
// Setup the ADCON1 register so Port A is all digital.
001A 3006 00309 MOVLW 06
001B 1683 00310 BSF 03.5
001C 009F 00311 MOVWF 1F // ADCON1 = 0x06
// This looks like a bug. They're setting ADCON0 to 7.
// That turns on the A/D module and it starts an A/D conversion.
// But it probably has no bad effect.
001D 3007 00312 MOVLW 07
001E 1283 00313 BCF 03.5
001F 009F 00314 MOVWF 1F // ADCON0 = 0x07
|
You could turn off the A/D converter by putting this line
at the start of main():
setup_adc(ADC_OFF);
-----------------------------------------------------------
Since you said nothing runs at all, I would do this:
1. Make sure your programmer is really setup for the 16F877A.
The "A" chip has a different programming algorithm than
the "non-A" chip.
In other words, make sure that your program is compiled for
the "A" chip, and that your programmer is configured for the "A" chip.
2. Make sure your programmer has up-to-date firmware, so
that it's guaranteed to work with the "A" chip.
3. Before you program the chip, do an "Erase". -- Just to see
if it has any effect.
4. The "A" chips seem to be very sensitive to power supply decoupling.
On the 40-pin DIP package, put a 0.1 uf (100 nf) capacitor between
each Vdd pin and Ground. This gives each Vdd pin its own cap.
5. Just on the chance that something is wrong with the setup for
Port A (whether the fault of the compiler, or some errata) try
blinking a LED on Port B, instead.
Questions:
Quote: | ccs pcw 3.168 which has the header file for the 16F877A but it
doesnt show up as a device which i can select via tools>device selector |
1. Is this a Demo version of the compiler ?
2. Does your test board permit you to test a 16F877, and then pull it out
and insert an "A" chip in its place, and thus test the "A" chip in the exact
same circuit ? (So the only variable is the PIC chip itself).
3. Is there anything out-of-the-ordinary in your test setup ?
Such as using a low voltage for Vdd ? |
|
![](templates/subSilver/images/spacer.gif) |
Coder Guest
|
|
Posted: Sun Jun 13, 2004 10:50 pm |
|
|
PCM Programmer thanks for the previous post, but unfortunately the ADC_OFF didnt work. i saw that in the migration document microchip had on their site, and at some point was thinking the same thing. but i have some other peripharals on port B and C which should have given me some positive feed back if the pic was operating properly.
tried doing the suggested experiments with the following results,
1. i have tried programming several different chips of 16F877A via a picstart PLUS and a ICD 2, with the correct "A" option with no luck.
2 i then upgraded the firmware on the ICD 2 since i was using MPLAB 6.1 before. but even after upgrading it through the new firmware (OS) present in the new MPLAB 6.53 it gives me zilch.
3. i tried this a couple of times with no luck
4. tried this as well although with 30nF-47nF caps. im guessing the change in the caps wont do that much of harm.
5. tried using ports B and C. no luck :(
following are the answers to the questions put foward
1. compiler is a fully lisenced copy. although as i had mentioned before i could not see the 16F877A or the 16F876A (or any other "A" varients) inside the device selector, but the header files for these are included in the devices folder.
2. i currently have 1 PCB and a testing breadboard. i have a 876 and a 877A mounted side by side on the breadboard, which is where i do all my testing after i figured out that there was nothing wrong with my PCB and the fault was with the PIC. i have tested all the voltages and they are as the data sheet recomends. i.e. vdd @ 5v vss @ 0v vpp @ 4.90v (i have tested the circuit after making this a direct connection to Vdd (like on the 876) but with no positive reaction).
3. i guess i cover this in the previous answer. no there is nothing out of the ordinary in the test set-up. its very much a simple 2 vdd (for 877A), 2 vss , Xtal via bypass caps, and MCLR* via a resistor cap network (also tested through a plain 100ohm connected to Vdd). and now the decoupling caps near the PIC Vdd lines.
further i have tested this with a number of Xtals i.e. 4Mhz , 10Mhz , 20 Mhz and currently most testing done via a 17.34Mhz .
how can this chip be so unstable when the 876 was rock solid? or is there somthing trivial that im missing.
one more thing is that i read in the migration sheet that the minimum Xtal driving voltage has been changed from 0.7Vdd to 1.6V this was parameter number D042A (Vih) in the migration sheet. i dont know how this affected the setup, thus since all else was failing i tried biasing the Xtal input with a 47Kohm resistor feeding Vdd. with no luck..
at this point i guess i can say that ive tried everything , except change the compiler. which im suspecting the most right now. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Mon Jun 14, 2004 7:15 am |
|
|
When using analog port of 877A as digital I/O, try all these three together
setup_adc( ADC_OFF ); // this is not enough !
setup_adc_ports( NO_ANALOGS ); // adding this for 877
setup_comparators(NC_NC_NC_NC); // this might be necessary for 877A |
|
![](templates/subSilver/images/spacer.gif) |
Coder Guest
|
|
Posted: Mon Jun 14, 2004 7:51 am |
|
|
just tried that ... but its still dead. ive changed between 3 different 877A chips as well. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jun 17, 2004 1:12 pm |
|
|
I bought a PIC16F877A-I/P chip from Digikey and it just arrived.
The date code on the part is 04223AG.
It worked. I installed PCM vs. 3.168 and compiled the following
program, which is the same one posted above, except for the clock
speed (since my demo board has a 4 MHz crystal on it).
I used MPLAB vs. 5.70.40 for this. My demo board is a MeLabs
PicProto64.
I looked at pins A1 and A2 with my oscilloscope, and they
are toggling once every second.
Based on this test, I don't think there is anything inherently
wrong with the 16F877A, at least for this kind of simple test.
Code: | #include <16F877A.h>
#use delay(clock=4000000)
#fuses XT, NOPROTECT, NOLVP,PUT,NOWDT,NOBROWNOUT
void main()
{
while(true){
output_high(PIN_A1);
output_low(PIN_A2);
delay_ms(1000);
output_low(PIN_A1);
output_high(PIN_A2);
delay_ms(1000);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|