- #include "Mini51Series.h"
- #define PAGE_SIZE 128
- uint32_t i, u32DFBADR, u32Data[PAGE_SIZE];
- void SYS_Init(void)
- {
- /* Unlock protected registers */
- SYS_UnlockReg();
- P01 = 1; // Set init state to high
- GPIO_SetMode(P0, BIT1, GPIO_PMD_OUTPUT); // Set to output mode
- /* Enable FMC ISP function */
- FMC_Open();
- /* Enable BOD function and setting Brown-out voltage level*/
- SYS_EnableBOD(SYS_BODCR_BOD_INTERRUPT_EN, SYS_BODCR_BOD_VL_4_4V);
- NVIC_EnableIRQ(BOD_IRQn); // Enable BOD interrupt
- /* Lock protected registers */
- SYS_LockReg();
- }
- void BOD_IRQHandler(void)
- {
- P01 = 0; // Set P0.1 state to low.
- SYS->BODCTL |= SYS_BODCR_BOD_INTF_Msk; // Clear BOD interrupt flag.
- // Disable BOD to avoid into BOD interrupt again.
- SYS_DisableBOD();
- NVIC_DisableIRQ(BOD_IRQn); // Disable BOD interrupt
- // Write test pattern to fill the whole page
- for(i = 0; i < PAGE_SIZE; i++)
- {
- FMC_Write(u32DFBADR + (i*4), u32Data[i]);
- }
- P01 = 1; // Set P0.1 state to high.
- }
|