cancel
Showing results for 
Search instead for 
Did you mean: 

Does anyone have a problem writing to Eeprom? When I try to write say a '0x80, a '0x3f' is reported as written So I stored my data as 4 bit nybbles, , which works (I'm using the discovery Board.) Russ

RHell
Associate

char *address = (char *) 0x4000;

void flashwrite(char dat)

   {

       // thanks to https://github.com/midnight-wonderer/stm8-eeprom-bug/blob/workaround-//method/src/firmware.c

 // one Mr. Sarun Rattanasiri

                                            while ((FLASH->IAPSR & FLASH_IAPSR_DUL)==0)                                    

                                                {

                                                 FLASH->DUKR = FLASH_RASS_KEY1;

                                                   FLASH->DUKR = FLASH_RASS_KEY2;

                                                }

                                                   *address = 0;

                                                  *address = dat;

                                                      FLASH->IAPSR &= ~FLASH_IAPSR_DUL;

   }

   

0 REPLIES 0