CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

checksum calculation as shown in mplabx

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
yossihagag1978



Joined: 04 Apr 2013
Posts: 20

View user's profile Send private message

checksum calculation as shown in mplabx
PostPosted: Sun Dec 08, 2024 8:17 am     Reply with quote

Hi
I am trying to calculate the checksum as shown in mplabx with 2 diffrenet pic's
One 18lf46k22 ant the other is 16lf1789. I am using Pcm compiler v5.008
With 18lf46k22 I succeeded (I attached the code below).
With 16lf1789 I did not success and don’t know why !!!!

Pic 18lf46k22 checksum ad shown in mplabx calculation Working :
int16 calc_pic_18_ checksum ()
{
int16, temp, Checksum;
int32, address;
For (address=0 ; address <getenv("Program_memory"); address+=2 )
{ temp= read_program_eeprom(address);
Checksum += (int8) temp ;
Checksum += (int8) (temp>>8) ;
}
For (address=0x300000 ; address <0x30000D; address+=2 )
{ temp= read_program_eeprom(address);
Checksum += (int8) temp ;
Checksum += (int8) (temp>>8) ;
}
return (Checksum);
}













Pic 16lf1789 checksum ad shown in mplabx calculation Not Working :
Using Pcm compiler v5.008
int16 calc_pic_16_ checksum ()
{
int16, temp, Checksum, temp1, temp2;
int32, address;
For (address=0 ; address <getenv("Program_memory"); address++ )
{
read_program_memory (address,&temp,2);
Checksum += temp ;
}
read_program_memory (0x8007,&temp1,2);
read_program_memory (0x8008,&temp2,2);
Checksum += temp1 ;
Checksum += temp2 ;
return (Checksum);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Sun Dec 08, 2024 9:08 am     Reply with quote

Why are you not calculating it the same way??????
The PIC16 has 14bit data. I assume you have to do the same as for
the PIC18, and sum the LSB then the MSB, not perform a 16bit addition.
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Dec 08, 2024 4:26 pm     Reply with quote

I wondered about the calculations but at +3*C here, decided to remove the sheet of ice in the driveway......

It'd also be interesting to see WHAT the checksum values are !
Seeing those might show what's wrong...
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Mon Dec 09, 2024 10:51 am     Reply with quote

The MPLAB description says it is a sum of the bytes. Not a sum of the words,
which is what is being done on the PIC16 version......
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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