S12X read paged flash 78 ( 0x780000 0x783FFF)

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

S12X read paged flash 78 ( 0x780000 0x783FFF)

Jump to solution
819 Views
firefox0005
Contributor I

Hi All,

 

I m trying to read the page  0x00780000 to 0x00783FFF ( global Address ) and calculate the CRC16 of the flash memory

 

 

#define FLASH_START_ADDR     0x00780000
#define FLASH_END_ADDR      0x00783FFF

 the function calculate every 64 bytes the crc and go out from the function again

 

void Flash_CalcCRC(void)
{
 // Puffer Zeiger auf aktuelles Byte mit Startadresse initialisieren

        static T_UC08* pucBuffer = (T_UC08*) FLASH_START_ADDR; // <-- wrong content

 // berechne nur ein Teil des Flashes
 T_UI16 uiBytesCounter = 0;
 // Temporäre Variable
 T_UI16 uiCryptPos = 0;

 // nur eine gewisse Anzahl an Byte berechnen und die Funktion wieder verlassen
 for (ulNumLoops ; (ulNumLoops <= FLASH_END_ADDR) && (uiBytesCounter < 64 ); ulNumLoops++)
 {
  // Bytes Zähler inkrementieren
  uiBytesCounter++;
  // Word aus Puffer in uiCryptPos kopieren
  uiCryptPos = (T_UI16) *pucBuffer; // also wrong
  // Pufferzeiger inkrementieren
  pucBuffer++;
  // EXOR mit RückgabeCRC
  uiCryptPos ^= uiFlashCRC16;
  // CryptArrays einrechnen
  uiFlashCRC16 = *(T_UI16*)(uiCRC16l + (uiCryptPos & 0x000F)) ^
       *(T_UI16*)(uiCRC16h + ((uiCryptPos & 0x00F0) >> 4)) ^
       (uiFlashCRC16 >> 8);
 }

 if ( ulNumLoops == FLASH_END_ADDR )
 {
  ucFinishFlag = 1;
  Flash_SetCRC16(uiFlashCRC16);
 }
}

 MY PROBLEM is, when I try to read the flash memory, see uiCryptPos or *pucBuffer, in the debug modus, the content of memory is wrong! 

 

My function works very good, when I calculate the page  at start address 0x007F4000 to 0x007F7FFF

 

I dont know what to do and there is no help in the web concerning my problem.

 

thanks for help in advance

 

best regards

Labels (1)
Tags (1)
0 Kudos
1 Solution
289 Views
CrasyCat
Specialist III

Hello

 

Please try to avoid multiple post for the same issue.

 

Look at http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&thread.id=7558

for an answer to this one.

 

CrasyCat

View solution in original post

0 Kudos
1 Reply
290 Views
CrasyCat
Specialist III

Hello

 

Please try to avoid multiple post for the same issue.

 

Look at http://forums.freescale.com/freescale/board/message?board.id=16BITCOMM&thread.id=7558

for an answer to this one.

 

CrasyCat

0 Kudos