I'm trying to compute a CRC32 for the application code on an 8052 embedded platform.
The following is given as a guide to calculating the CRC :
void TestChecksum()
{
unsigned short calc = 0;
/* Run the checksum algorithm */
calc = slow_crc16(0, (unsigned char *) ChecksumStart, (ChecksumEnd - ChecksumStart+1));
/* Rotate out the answer */
unsigned char zeros[2] = {0, 0};
calc = slow_crc16(calc, zeros, 2);
etc...
}
where
unsigned short slow_crc16(unsinged short sum, unsigned char *p, unsigned int len)
{
while (len--)
{
int i;
unsigned char byte = *(p++);
for (i = 0; i < 8; ++i)
{
etc...
}
}
The problem with the example is that the pointer automatically points to XData whereas I'm after CODE. I know the address of the code from which I would like to calculate the CRC, say 0x2000 to 0x2FFF.
Is it possible to define a pointer as, say:
uint8_t __code *Ptr;
And pass in an address, the 0x2000, as a uint32 to the CRC function ?
Basically I can't work out how to get a pointer to point to an address which is actually stored as a variable.
Any help would be appreciated, I'm not sure this is even possible.