AnsweredAssumed Answered

Write Flash

Question asked by Gregory Clement on Sep 7, 2016
Latest reply on Sep 23, 2016 by Edward Karpicz

Hello;

I program a microcontroller mc9s08sh4 .

 

I used the various discussing how to read and write to the flash . I use the example given on the forum:

Unable to write S08 flash in run mode 

 

I manage to save one time a character, but I can not do it after.

 

Here is my example code :

 

void main(void)
{

unsigned char Byte_To_Be_Programmed = 'D';

/* Start by copying the Flash Routine to RAM */
CopyInRAM();

/* Init Flash Clock Divider */
FlashInit();


if (Flash_Program(0xFFB0, Byte_To_Be_Programmed))
{
/* Error while programming a Byte, write your error handling here */
}


Byte_To_Be_Programmed = 'B';

if (Flash_Program(0xFFB0, Byte_To_Be_Programmed))
{
/* Error while programming a Byte, write your error handling here */
}



EnableInterrupts;

for(;;)
{

__RESET_WATCHDOG();
}

 

The first time , the variable 'D' ( 0x44 ) is stored in memory .

 

As against the variable 'B' does not register properly ( 0x40 )

 

Whatever the second variable , it is always 0x40 .

 

Do you have an idea of the problem?

 

Thank you for your help. DSL for my English

Outcomes