AnsweredAssumed Answered

Issue with the SetPage method in Codewarrior 5.9 targeting HCS08

Question asked by Christopher Smith on Apr 24, 2015
Latest reply on Apr 28, 2015 by Christopher Smith

This question is in regards to CodeWarrior IDE version 5.9.0 targeting processor family HCS08. I am having an issue writing to flash using the methods provided through CodeWarrior. I am reading from and writing to a buffer using the GetBytePage, GetWordPage, SetBytePage, and SetWordPage methods. This buffer is in turn being read from and written to flash using the SetPage and GetPage methods. The problem occurs when I attempt to use the SetPage method: whenever the program attempts to write the buffer to flash, the results are erratic. Sometimes my registers are corrupted, sometimes my microcontroller locks up until the watchdog timer expires. If I comment out the SetPage method, my code functions as expected. Does anyone have a suggestion as to what the problem(s) may be?

 

Below is the section of code I am using to read from and write to flash.

 

     const word Buffer_Address = 0xDD00;

 

     // Reading from flash

 

     Flash_DataPtr2Addr(Buffer_Address);

 

     Flash_GetPage(Buffer_Address);

 

     Flash_GetWordPage(1, &Word1);

     Flash_GetWordPage(3, &Word2);

     Flash_GetWordPage(5, &Word3);

     Flash_GetWordPage(7, &Word4);

     Flash_GetBytePage(9, &Byte1);

     Flash_GetBytePage(10, &Byte2);

     Flash_GetBytePage(11, &Byte3);

 

 

     // Writing to flash    

 

     Flash_DataPtr2Addr(Buffer_Address);

 

  Flash_SetWordPage(1, Word1);
  Flash_SetWordPage(3, Word2);
  Flash_SetWordPage(5, Word3);
  Flash_SetWordPage(7, Word4);
  Flash_SetBytePage(9, Byte1);
  Flash_SetBytePage(10, Byte2);
  Flash_SetBytePage(11, Byte3);

     

  Flash_EraseSector(Buffer_Address);

     

  Flash_SetPage(Buffer_Address);

Outcomes