Hello All,
In my current project at start up I need to check the checksum at start up with which I have problem.
My Environment is Controller
IC18F45K80, Compiler:XC8, IDE:MPLAB X 2.20, Debugger: ICD3.
Gone through the programming specification, it mentioned as
The checksum is calculated by summing the following:
• The contents of all code memory locations
• The Configuration Word, appropriately masked
• ID locations.
followed section "CHECKSUM COMPUTATION" describes as
for code protect none, check sum should be calculated as
-------------------------------------------------------------------------------------
SUM(0000:0FFF) + SUM(1000:1FFF) + SUM(2000:3FFF) + SUM(4000:5FFF) +
SUM(6000:7FFF) + (CONFIG1L=5D & 5D) + (CONFIG1H=08 & DF) +
(CONFIG2L=7F & 7F) + (CONFIG2H=7F & 7F) + (CONFIG3L=00 & 00) +
(CONFIG3H=89 & 89) + (CONFIG4L=91 & 91) + (CONFIG4H=00 & 00) +
(CONFIG5L=0F & 0F) + (CONFIG5H=C0 & C0) + (CONFIG6L=0F & 0F) +
(CONFIG6H=E0 & E0) + (CONFIG7L=0F & 0F) + (CONFIG7H=40 & 40)
with bank value 0x848A; 0xAA at 0 and Max Address; page DS39972B-page 42
---------------------------------------------------------------------------------
I don't understand what (CONFIG1L=5D & 5D), bank value and (0xAA at 0 and Max Address), what I am suppose to do with these?
I calculated checksum using below code
Code:
unsigned int calaculateCRC(void)
{
static unsigned int index;
unsigned int temp_Low,temp_high;
static unsigned int sum=0;
EEPGD=1;
CFGS=0;
RD=1;
TBLPTRU =0x00;
TBLPTRH =0x00;
TBLPTRL = 0x00;
for(index=0;index<CODE_END_ADDRESS;index=index++)
{
asm("TBLRD*+");
temp_Low=TABLAT;
asm("TBLRD*+");
temp_high=TABLAT;
sum^=((temp_high<<8)|temp_Low);
}
EEPGD=1;
CFGS=1;
RD=1;
TBLPTRU =0x30;
TBLPTRH =0x00;
TBLPTRL = 0x00;
for(index=0;index<LIMIT;index=index++)
{
asm("TBLRD*+");
temp_Low=TABLAT;
asm("TBLRD*+");
temp_high=TABLAT;
sum^=((temp_high<<8)|temp_Low);
}
return sum;
}
the checksum is not matching with dashboard checksum in MPLAB X. what is that I am missing. any suggestion would be of great help.
thanks in advance.