Skip to main content
alessandra2
Associate
December 3, 2003
Question

CRC check

  • December 3, 2003
  • 2 replies
  • 774 views
Posted on December 03, 2003 at 17:21

CRC check

This topic has been closed for replies.

2 replies

alessandra2
Associate
May 17, 2011
Posted on May 17, 2011 at 11:35

I would use ST9 to write a C program to check RAM and ROM (crc check). How could I direct the software to check absolut addresses? Could I have a little related example?

gmeyer
Associate II
May 17, 2011
Posted on May 17, 2011 at 11:35

It would be nice if the compiler supported an instruction like:

wData = (*((huge unsigned int *)(dwAddress)));

The compiler doesn't support this so we've created a routine. Here it is. Obviously you would want to work on every address in a page before swapping to the next page when computing your CRC.

BYTE byReadAddress(DWORD dwAddress)

{

BYTE byReturn;

BYTE byPage;

BYTE byOldPage;

BYTE * pbyOffset;

// Disable Interrupts so only this routine uses the DPP while it is changed.

di();

SWITCH_TO_DPR_PAGE;

// Find the 16k page boundary

byPage = (BYTE)(dwAddress / 0x4000);

byOldPage = DPR0;

// Calculate 14bit (16k) offset

pbyOffset =(BYTE *)(dwAddress & 0x3FFF);

// set the page, Read the byte & restore the page

DPR0 = byPage;

byReturn = *pbyOffset;

DPR0 = byOldPage;

ei();

return byReturn;

}