gpt4 book ai didi

stm32 - 如何在代码本身中找出闪存的大小?

转载 作者:行者123 更新时间:2023-12-05 02:00:17 25 4
gpt4 key购买 nike

我想在代码本身中获取flash的限制地址,或者至少是这个flash的大小。

stm32f302xc.h文件中只找到flash的起始地址,没有找到结束地址。

/** @addtogroup Peripheral_memory_map
* @{
*/

#define FLASH_BASE 0x08000000UL /*!< FLASH base address in the alias region */
#define SRAM_BASE 0x20000000UL /*!< SRAM base address in the alias region */
#define PERIPH_BASE 0x40000000UL /*!< Peripheral base address in the alias region */
#define SRAM_BB_BASE 0x22000000UL /*!< SRAM base address in the bit-band region */
#define PERIPH_BB_BASE 0x42000000UL /*!< Peripheral base address in the bit-band region */

什么定义对此负责,谢谢。

最佳答案

引用手册中描述了你想要的RM036629.2 内存大小数据寄存器部分。

ST 提供此功能,但出于某种原因,它们并不总是提供一种在 header 中访问它的简单方法。

这个寄存器的地址是FLASHSIZE_BASE。您必须在运行时阅读它,例如:

uint16_t flash_size_kb = *(const uint16_t*)FLASHSIZE_BASE;

关于stm32 - 如何在代码本身中找出闪存的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67431388/

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