STM32F103C8T6中数据存到FLASH哪里
时间: 2023-09-28 14:09:58 浏览: 56
在STM32F103C8T6中,数据可以存储在Flash的两个区域中:主存储器(Main Memory)和系统存储器(System Memory)。主存储器是应用程序使用的存储区域,而系统存储器则用于存储引导加载程序(Bootloader)和其他系统级别的功能。
如果您想在应用程序中将数据保存到Flash中,可以使用Flash编程库提供的函数。通过这些函数,您可以将数据保存到Flash中的特定地址。请注意,Flash编程库只能在主存储器中使用。
以下是使用Flash编程库将数据保存到Flash的示例代码:
```
#include "stm32f10x_flash.h"
uint32_t flash_address = 0x08008000; // Flash中的地址
// 将数据保存到Flash中
void save_to_flash(uint32_t data)
{
FLASH_Unlock(); // 解锁Flash
FLASH_ErasePage(flash_address); // 擦除Flash中的页面
FLASH_ProgramWord(flash_address, data); // 将数据编程到Flash中
FLASH_Lock(); // 锁定Flash
}
// 从Flash中读取数据
uint32_t read_from_flash()
{
return *(uint32_t*)flash_address; // 读取Flash中的数据
}
```
请注意,使用Flash编程库将数据保存到Flash中会擦除整个Flash页面,因此请务必备份Flash中的所有数据。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)