gpt4 book ai didi

stm32 - 使用 HAL 驱动程序在 stm32 上进行 EEPROM 仿真

转载 作者:行者123 更新时间:2023-12-04 07:18:59 36 4
gpt4 key购买 nike

我正在尝试在 stm32f0 上模拟 EEPROM。有一个application note STM 提供。

样本中main.c ,

int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f0xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f0xx.c file
*/
/* Unlock the Flash Program Erase controller */
FLASH_Unlock();

/* EEPROM Init */
EE_Init();

/* --- Store successively many values of the three variables in the EEPROM ---*/
/* Store 0x1000 values of Variable1 in EEPROM */
for (VarValue = 1; VarValue <= 0x64; VarValue++)
{
EE_WriteVariable(VirtAddVarTab[0], VarValue);
}

/* read the last stored variables data*/
EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);


/* Store 0x2000 values of Variable2 in EEPROM */
for (VarValue = 1; VarValue <= 0xC8; VarValue++)
{
EE_WriteVariable(VirtAddVarTab[1], VarValue);
}

/* read the last stored variables data*/
EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);
EE_ReadVariable(VirtAddVarTab[1], &VarDataTab[1]);


/* Store 0x3000 values of Variable3 in EEPROM */
for (VarValue = 1; VarValue <= 0x1C2; VarValue++)
{
EE_WriteVariable(VirtAddVarTab[2], VarValue);
}

/* read the last stored variables data*/
EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);
EE_ReadVariable(VirtAddVarTab[1], &VarDataTab[1]);
EE_ReadVariable(VirtAddVarTab[2], &VarDataTab[2]);

while (1);
}
Flash_Unlock()是STM标准外设库中使用的函数。但是,我使用的是自动生成使用 HAL 驱动程序的代码的 CubeMX。是 Flash_Unlock()必须先调用才能使用 EEPROM_emulation API?如果是,则调用 Flash_Unlock() 的 HAL 等效项是什么? ?在 CubeMX 上进行任何特殊配置设置以使用 EEPROM 仿真?

最佳答案

ST Microelectronics 确实提供了使用 HAL 驱动程序的示例代码。问题是他们的文档到处都是,谷歌搜索可能无法找到正确的页面。

这是对的document为你。

搜索“EEPROM_Emulation”。您会发现 NUCLEO -F091RC 固件示例下提供了示例代码。示例代码应该可以回答您的问题。

关于stm32 - 使用 HAL 驱动程序在 stm32 上进行 EEPROM 仿真,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37387433/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com