发新帖我要提问
12
返回列表
打印
[DemoCode下载]

计算掉电時储存512字节数据所需时间和电容值

[复制链接]
楼主: dongnanxibei
手机看帖
扫描二维码
随时随地手机跟帖
21
dongnanxibei|  楼主 | 2019-5-12 22:59 | 只看该作者 |只看大图 回帖奖励 |倒序浏览
#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.
}

使用特权

评论回复
22
dongnanxibei|  楼主 | 2019-5-12 22:59 | 只看该作者
int main(void)
{
/* Before use this sample code, we need to set data flash for
erasing and writing test pattern */
/* Init System, set GPIO mode and enable BOD function*/
SYS_Init();
/* Fill test pattern */
for(i = 0; i < PAGE_SIZE; i++)
{
u32Data[i] = i;
}
// Unlock protected registers for flash erase and program.
SYS_UnlockReg();
// Read data flash base address.
u32DFBADR = FMC_ReadDataFlashBaseAddr();
/* Erase one page data flash before write test pattern*/
FMC_Erase(u32DFBADR);
while (1);
}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则