Building a Checksum with paged ROM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Building a Checksum with paged ROM

2,017 Views
buhr
Contributor I
Hi,
 
I need help concerning the following:
 
I have to build a CRC32-Checksum of the whole FlashRom and parts of the EEP of a MC9S12DP256. The problem is: the memory is configured as "paged", so I have to use the PPAGE - register. Unfortunately the code is located on Page 38, which is not a fixed adress page. Therefor when I use the PPAGE register, the controller runs anywhere.
 
Is there any solution how to read the ROM by using a pointer from any page or is the only way to locate the code on a fixed adress page? This would be very difficult because these pages are nerly completely full with data, tables, flashbootloader, Lib's, ...
 
Hope someone can help me.
 
Thanks!
 
Heiko 
Labels (1)
0 Kudos
5 Replies

570 Views
kef
Specialist I
You can have *small* routine in "fixed" page that would just switch PPAGE, fetch some data, restore PPAGE and return to your CRC checking routine. CW large memory model does the same when you dereference far data memory pointer.
0 Kudos

570 Views
buhr
Contributor I
Thanks for your fast reply. So there's no other way than reading from fixed pages, right?
 
Your proposal is just the way I was thinking about in this moment. It means one more subroutine call, but the stack-size should manage this.
Meanwhile I found a module that could be moved to a non-fixed page, so hopefully I have enough space for the complete CRC function.
 
Heiko
0 Kudos

570 Views
kef
Specialist I
Yes, your paged memory access routine should run not from paged memory. Access routine that will switch PPAGE should run from nonpaged 4000-7fff or c000-ffff flash, RAM or EEPROM. No more options, except maybe nonpaged external memory.
0 Kudos

570 Views
buhr
Contributor I
Ok! After moving another module from fixed page to a non-fixed page i had enough space for the CRC routine. Now it works fine.
 
Thank you for your support!
 
Heiko
0 Kudos

570 Views
dkelly
Contributor I
I don't understand all of your concern. If using Codewarrior C then you can reference paged FLASH using *far data modifier. The compiler will link to an intrinsic support function loaded in NON_BANKED segment which will transparently handle PPAGE for you no matter where your code is running from.

I recently had an issue where my bootloader/updater needed to be able to replace all of FLASH while running from RAM. I had to hunt down and make sure the compiler was not calling any intrinsic support routines because they would not exist during certain phases of a firmware update.

Code doesn't paste very well here but this is a routine I use:

//============================================================================
//
// crc paged FLASH.
//
// Warns saying DPAGE is being used but on examination of generated code
// it calls _LOAD_FAR_8 routine which uses PPAGE, which is correct. Mute
// this warning rather than fight CW. -CpPPAGE breaks other things.
//
// Uses Codewarrior CRC_CCITT algorithm.
//
//============================================================================
#pragma MESSAGE DISABLE C12002
UINT16
crc_flash( UINT16 crc, UINT08 *far start, UINT08 *far end )
{
_RESET_COP_(); // need to time this loop and make sure

do {
crc = cw_crc_ccitt_16( crc, *start++ );
}
while( start end );

_RESET_COP_();
return crc;
}
#pragma MESSAGE DEFAULT C12002
0 Kudos