Skip to main content
Visitor II
September 12, 2019
Question

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

  • September 12, 2019
  • 0 replies
  • 477 views

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;

   }

   

    This topic has been closed for replies.