BTW, this is for psoc 4 with 16 KB of memory.
I'm assuming you mean a checksum of the binary op codes, If so, then one method that would be pretty easy, is to write a script to create a checksum based on the .hex file output of the compiler. If you are wanting to use it in code however, then you might have to write a checksum yourself that reads the flash and computes the checksum.
I wrote code to calculate the checksum from 0x0000 to 0x3FFF, for 16 KB memory, but it doesn't match up to the checksum in PSoc Programmer software. What method does the PSoC Programmer use?
Hello dv89, I'm not sure what the PSoC Programmer does. I imagine it does a checksum on the entire flash hex file on the PC, and then loads that into the checksum location when it programs the flash.
It seems to mention reading the entire flash hex file, and then computing the checksum before writing it to the chip when programming.
I would guess it is using a simple accumulation checksum. Add all bytes together, then keep only the lowest number of bytes that fit the size of checksum you are wanting to keep. Now, this value we will call the SUM. Using some math, we calculate what number when added to the SUM will give us all zeroes. CHECKSUM + SUM = 0. Solve for the CHECKSUM, and that will be the value that the programmer calculates to put into the flash storage (I believe).
Here is another document containing useful information about the programmer: http://www.cypress.com/file/44411/download
So i have this code in my project:
uint8 * MyPointer = (uint8*) 0x0000; // Initialize to point to address 0x0000
for(i=0x0000; i < 0x3FFF; i++)
Why when i read the contents of the flash memory the checksum does not match to that of the PSoC programmer? The code above is to add up all the bytes in my 16 KB of flash memory but it returns invalid data at certain parts of the memory. For exampe if i read address 0x0005, the data at that location is 0x11 but when the pointer returns the value of that address it gives me a 0x93. What is going on here? Am i pointing to somewhere else?
Probably because address 0x0005 is ram and not code.
Please have a look at this.
This contains describes the PSoC® 4 IEC 60730 Class B and IEC 61508 safety integrity level (SIL) Safety Software Library and includes example projects with self-check routines to help ensure reliable and safe operation.