infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 2 of 2

Thread: How to realize data saving into FLASH while power supply drops?

  1. #1
    New Member New Member julian1027 is on a distinguished road
    Join Date
    Aug 2018
    Posts
    4
    Points
    47.5

    How to realize data saving into FLASH while power supply drops?

    I'm using XMC4800, and the code is as follow:

    Code:
    #define E_EEPROM_XMC4_FLASH_BANK0_BASE     (0x0c01c000U)
    uint32_t temp_count[] = {0};
    
    void XMC_FLASH_Program(uint32_t *address, const uint32_t *data, uint8_t length)
    {
      uint32_t idx;
    
      for (idx = 0U; idx < length; idx += 2U)
      {
        XMC_FLASH_lLoadPageCommand(data[idx], data[idx + 1U]);
      }
    
      XMC_FLASH_lWritePageCommand(address);
    
      while ((FLASH0->FSR & (uint32_t)FLASH_FSR_PBUSY_Msk) != 0U){}
    }
    
    void NMI_Handler(void)
    {
    	XMC_SCU_TRAP_Disable(XMC_SCU_TRAP_BROWNOUT);
    	temp_count[0]++;
    	XMC_FLASH_Program(E_EEPROM_XMC4_FLASH_BANK0_BASE, temp_count, 1);
    	__BKPT();
    }
    
    int main(void)
    {
      DAVE_STATUS_t status;
    
      status = DAVE_Init();           /* Initialization of DAVE APPs  */
    
      if(status != DAVE_STATUS_SUCCESS)
      {
        /* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
        XMC_DEBUG("DAVE APPs initialization failed\n");
    
        while(1U)
        {
    
        }
      }
    
      temp_count[0] = *( __IO uint32_t*)E_EEPROM_XMC4_FLASH_BANK0_BASE;
      XMC_FLASH_EraseSector(E_EEPROM_XMC4_FLASH_BANK0_BASE);
      XMC_SCU_TRAP_Enable(XMC_SCU_TRAP_BROWNOUT);
      XMC_SCU_POWER_EnableMonitor(145, 1);
    
      while(1U)
      {
    
      }
    }
    What I want is the value of E_EEPROM_XMC4_FLASH_BANK0_BASE increases by 1 when I shut down the power supply.
    I wonder whether I'm doing it in the right way, cause it doesn't work.

  2. #2

    Infineon Employee
    Infineon Employee
    jferreira will become famous soon enough
    Join Date
    Oct 2012
    Posts
    599
    Hi,

    Are you not missing the XMC_FLASH_lEnterPageModeCommand(); in the XMC_FLASH_Program() function?

    Regards,
    Jesus
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

+ Reply to Thread

Tags for this Thread

Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.