Nov 12, 2018
09:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 12, 2018
09:21 PM
I'm using XMC4800, and the code is as follow:
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.
#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.
1 Reply
Nov 22, 2018
03:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 22, 2018
03:12 PM
Hi,
Are you not missing the XMC_FLASH_lEnterPageModeCommand(); in the XMC_FLASH_Program() function?
Regards,
Jesus
Are you not missing the XMC_FLASH_lEnterPageModeCommand(); in the XMC_FLASH_Program() function?
Regards,
Jesus