whn you say hex, do you mean hex display of 'binary' or do you mean hex20, where ASCII is used to represent hex records.
I mean the hex display of binary.
Check out AN2026. In the appendix of this app note, there is a description of the format of the hex file. There is a record called Checksum record, which stores the checksum of all the flash data. During programming, this stored checksum is compared with the checksum calculated on the flash data. So, if you want to change the last two bytes of the flash data, you need to calculate the checksum of the flash and update this checksum record in the hex file for the programming to pass.
Can anyone tell me how to start writing program since i m beginner.
please send me some sample program that may help me to write program using assembly as well as using C.
To check program memory means you want to confirm whether the CRC of program Flash in hex file is same as CRC of p-flash after downloading/ flashing hex into controller.
In this way you are checking the physical memory is damaged or not.
Things you need to do is.
Write down your own routine to calculate CRC of p flash with an algorithm (CRC-16 or CRC-32).
Calculate CRC of hex file using srec tool using same algorithm (CRC-16 or CRC-32).
Append CRC at particular address in hex file. (You can place calculated CRC at unused p flash area )
Now at run time your own routine will calculate CRC of p flash. You should have added a logic to compare calculated CRC with stored CRC at particular address.
Refer below link for reference.
Hex file CRC calculation using Srecord tool :