![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
TL
Joined: 15 Sep 2003 Posts: 75
|
18F6722 programming problem |
Posted: Wed Mar 24, 2010 9:03 am |
|
|
Hi,
1. I have an 18F6720 hex file which can be programmed into a 6720 with no problems using ICD-S40 or PM3 programmer. The 6720 works.
2. I then use the same set of source files from 1 and made the following changes:
a. deleted the following line:
Code: |
#FUSES NOOSCSEN // Oscillator switching is disabled, main oscillator is source
|
I deleted the above line because the 6722 does not have this fuse setting.
b. replaced the following line
Code: | #include <18F6720.h> |
with
Code: | #include <18F6722.h> |
c. then compiled successfully and created a hex file for 6722.
However, when I tried to program this hex file into a 6722 using ICD-S40, I got verification errors (ie. many program memory errors and configuration fuses errors.
FUSES
Actual:
C1 00 1E 16 85 F3 00 80 C0 0F E0 FF 40 FF
CPD, CPB
Expected:
C1 00 1E 16 85 F3 00 80 C0 FF E0 FF 40 FF
NOCPD, NOCPB
3. The header details are:
Code: |
#include <18F6722.h>
#device *=16
#device ADC=10
#FUSES NOWDT // No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES PUT //Power Up Timer
#FUSES PROTECT //Code protected from reading
// #FUSES NOOSCSEN //Oscillator switching is disabled, main oscillator is source
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV42 //Brownout reset at 4.2V
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOCPD //No EE protection
#FUSES NOLVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOWRT //Program memory not write protected
#FUSES NOCPB //No Boot Block code protection
#FUSES NOEBTRB //Boot block not protected from table reads
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOWRTD //Data EEPROM not write protected
#FUSES NOWRTC //configuration not registers write protected
#FUSES NOWRTB //Boot block not write protected
// 4MHz clock
#use delay(clock=4000000, restart_wdt)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS, STREAM=COMMS, restart_wdt)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, ERRORS, STREAM=VTS, restart_wdt)
#use rs232(baud=9600, parity=N, xmit=PIN_G3, bits=8, STREAM=PRINTER, restart_wdt)
#use rs232(baud=9600, xmit=PIN_E5, rcv=PIN_E4, ERRORS, STREAM=USB, FORCE_SW, restart_wdt)
|
4a. Having spent many hours on it, I tracked down the lines that gave verification errors:
Code: |
fprintf(PRINTER, "\rNo: %u ID: %s", i+1, VIN);
fprintf(PRINTER, "\rWt1: %ldkg", tmp);
fprintf(PRINTER, "\rWt2: %ldkg", tmp);
|
4b. ie. If I remove the lines in 4a, the programming is successful and the target works.
4b. However, the following lines can be added and no verification errors are found after programming which is quite strange:
Code: |
fprintf(PRINTER, "\rDate: %s Time: %s\r", tmpDateStr, tmpTimeStr);
fprintf(PRINTER, "\r\r\r\r\r\r\r\r");
|
5. PCWH V3.249.
6. I have created a simple program and programmed into the 6722 target successfully and it works. Therefore the 6722 is definitely a working chip.
What have I done wrong? Thank you. |
|
![](templates/subSilver/images/spacer.gif) |
TL
Joined: 15 Sep 2003 Posts: 75
|
|
Posted: Wed Mar 24, 2010 9:10 am |
|
|
In 6, the simple program is a separate program. Thanks. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 24, 2010 11:40 am |
|
|
Try this:
1. Delete the Protect fuse line:
Quote: | #FUSES PROTECT //Code protected from reading |
2. Do a full chip erase, using your programmer.
3. Then try your program again. (But don't use Protect fuse). |
|
![](templates/subSilver/images/spacer.gif) |
TL
Joined: 15 Sep 2003 Posts: 75
|
|
Posted: Thu Mar 25, 2010 6:00 am |
|
|
Hi PCM Programmer,
Thank you very much for your comments. You have saved me a lot of time. I really appreciated your help.
As you said do a full erase which I did, but couldn't do it for my ICD-S40. I found out that the cause was due to an older version of firmware in the ICD-S40, but when I upgraded it to the latest version (V2.74), the programming worked successfully even with the PROTECT fuse line in the code. However, I couldn't erase all the memory.
I then used ICD-U40 with firmware V2.74 which programmed successfully and erased all the memory with no problems. |
|
![](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
|