Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Stm32 如何在代码中找到闪存的大小?_Stm32_Hal - Fatal编程技术网

Stm32 如何在代码中找到闪存的大小?

Stm32 如何在代码中找到闪存的大小?,stm32,hal,Stm32,Hal,我想得到代码本身中闪存的限制地址,或者至少是这个闪存的大小 我在stm32f302xc.h文件中只找到了闪存的开始地址,但没有找到结束地址 /** @addtogroup Peripheral_memory_map * @{ */ #define FLASH_BASE 0x08000000UL /*!< FLASH base address in the alias region */ #define SRAM_BASE 0x2000

我想得到代码本身中闪存的限制地址,或者至少是这个闪存的大小

我在
stm32f302xc.h
文件中只找到了闪存的开始地址,但没有找到结束地址

/** @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 */
/**@addtogroup外围设备\u内存\u映射
* @{
*/
#在别名区域中定义闪存基址0x0800000UL/*!<闪存基址*/
#在别名区域中定义SRAM_BASE 0x200000UL/*!

是什么定义导致了这一点,谢谢。

参考手册第29.2节“内存大小数据寄存器”中描述了您需要什么

ST提供了这种功能,但由于某些原因,它们并不总是提供一种在标题中访问它的简单方法

此寄存器的地址是
FLASHSIZE\u BASE
。您必须在运行时读取它,例如:

uint16_t flash_size_kb = *(const uint16_t*)FLASHSIZE_BASE;