Join our technical discussions about Freescale Microcontrollers: M68HC12. (Freescale Semiconductor is a Subsidiary of Motorola).
|
My (safety related) application has to recognize changes in the code (in the Flash). I have to calculate a CRC checksum over the whole code in the Flash. Thus I have to access every Flash cell in an absolute addressing manner. Any idea how to read out the whole Flash this way? Any hint is highly appreciated. Thanks, Markus |
|
|
|
Markus, check out: CodeWarrior Manuals\pdf\Manual SmartLinker.pdf chapter "Linker Defined Objects". Search for "checksum" to get there as well. The linker generates special symbols for it, e.g. . "__SEG_START_": start address of the segment . "__SEG_END_": end address of the segment There is example code as well for it. Erich > -----Original Message----- > From: Roth Markus [mailto:] > Sent: Dienstag, 4. Februar 2003 14:04 > To: ' > Subject: [68HC12] Metrowerks user: How to access a specific Flash > position (absolute addressing)? > My (safety related) application has to recognize changes in the > code (in the > Flash). I have to calculate a CRC checksum over the whole code in > the Flash. > Thus I have to access every Flash cell in an absolute addressing manner. > > Any idea how to read out the whole Flash this way? > > Any hint is highly appreciated. > > Thanks, Markus > -------------------------------------------------------- > To unsubscribe from this group, send an email to: > To learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu |
|
Here is pseudo-code for an additive checksum (not a CRC) but you should get the jist: WORD checksum = 0x0000u; // initialize checksum value to zero BYTE pageVal; // Flash PPAGE values are from 30h to 3Fh WORD address; // Flash Page window at 8000h to C000h // Loop over all Flash pages. // for (pageVal = 0x30u; pageVal <= 0x3Fu; pageVal++) { // Set the PPAGE register to bring in the appropriate Flash // page into view. // PPAGE = pageVal; // Loop over all addresses in the page window. // for (address = 0x8000u; address < 0xC000u; address += 2) { // Add the 16 bits at `address' to the checksum. // checksum += *((WORD*) address); } } // Determine what the checksum should actually equal. // WORD expectedChecksum = readConfigParameter(EXPECTED_FLASH_CHECKSUM); // Compare the actual checksum to the expected checksum. // if (checksum == expectedChecksum) // Signify test as "Passed" else // Signify test as "Failed" --- In , Roth Markus <markus.roth@s...> wrote: > My (safety related) application has to recognize changes in the code (in the > Flash). I have to calculate a CRC checksum over the whole code in the Flash. > Thus I have to access every Flash cell in an absolute addressing manner. > > Any idea how to read out the whole Flash this way? > > Any hint is highly appreciated. > > Thanks, Markus |