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

How to calculate this crc16

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



Joined: 11 May 2008
Posts: 74

View user's profile Send private message

How to calculate this crc16
PostPosted: Sun Dec 30, 2012 12:52 pm     Reply with quote

I trigger my bootloader by sending rs232 command, so I have to write my own program on PC instead of siow function: "download software". I listened what siow program send by rs232 and i saw that before last row (hex file): "00000001FF" program send CRC (for hex file below is "FEE7").
Code:

:1000000015EF00F0EA6A050EE96EEF500DE0060EFE
:10001000016E006A002EFED7012EFBD77B0E006E0C
:10002000002EFED7EF2EF3D71200F86AD09EEA6AB0
:10003000E96AC180C182C184C19693988A88C80E3A
:10004000056EE0DF93988A98C80E056EDBDFF5D762
:020050000300AB
:020000040030CA
:0E00000000220E0E000181000FC00FE00F4025
:00000001FF
;PIC18F452
;CRC=2F20  CREATED="30-gru-12 19:03"

CCS told me this is CRC16, but i looked for algorithm how to calculate as below:
http://www.lammertbies.nl/comm/info/crc-calculation.html
http://www.ccsinfo.com/forum/viewtopic.php?t=45645&highlight=crc16
but nothing fit.
I look into loader.c how it is calculate:
Code:

for (i=1; i<(buffidx-3); i+=2)
checksum += atoi_b16 (&buffer[i]);
checksum = 0xFF - checksum + 1;

but this 8bit crc for each row of hex file, i need to calculate all bytes in hex file.
Anybody know how to calculate it?


Best Regards,
Martin
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Sun Dec 30, 2012 1:56 pm     Reply with quote

try a SEARCH of this forum ???


also nice solutions in the code forum.
cmon don't be lazy......

here is a great one with c code

[url]
http://www.ccsinfo.com/forum/viewtopic.php?t=24977&highlight=crc16 [/url]


Last edited by asmboy on Sun Dec 30, 2012 1:59 pm; edited 1 time in total
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Dec 30, 2012 1:58 pm     Reply with quote

You didn't tell why you want to calculate the CCS-private CRC? It's not checked anywhere as far as I'm aware of.
Requan



Joined: 11 May 2008
Posts: 74

View user's profile Send private message

PostPosted: Sun Dec 30, 2012 2:49 pm     Reply with quote

Arrow asmboy
I am not lazy, i checked it also.
Arrow FvM
I would like to use bootloader in modbus line, so i have to create my own software to upload firmware(switch between rx and tx)
CCS told me that it is crc16 so i thought that is ordinary CRC16, but as You wrote i was wrong Crying or Very sad
I dont know what for is this crc because each row of hex contains crc and in loader.c after receiving each row, program calulate crc. I didn't see if in ccs bootloader example this crc is checking
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Dec 31, 2012 4:41 am     Reply with quote

Sounds like you are confusing two points:
- Hex files have a 8-Bit checksum at the end of each line. It's checked e.g. by the bootloader
- CCS hex files have a CRC16 in the last comment line. It's generation method is undocumented, but I assume you can get the information from CCS. It's not checked by the bootloader.
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Mon Dec 31, 2012 7:06 am     Reply with quote

and, seriously, a bootloader, really can't use it.
Problem is that a PIC has a lot less RAM than ROM. So the bootloader has to have already written most of the memory, by the time it reaches the the CRC. If it's bad, what has been written is screwed.
It almost certainly is standard CRC16. Have you read the Intel Hex format definitions?. They specify a CRC _option_ for the format, and quite a few programs can generate this. It check-sums the memory block, _not_ the transmitted data. So the block of memory represented by the file, has a checksum calculated on it using standard CRC16, and this is then appended as a 'comment' line to the end of the file. If you are trying to checksum the 'file', then it won't work.

Best Wsihes
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