(101)继续老师的库函数的讲解 :

++ 写入字:
c
/**
* @brief Programs a word at a specified address.
* @note This function can be used for all STM32F10x devices.
* @param Address: specifies the address to be programmed.
* @param Data: specifies the data to be programmed.
* @retval FLASH Status: The returned value can be: FLASH_ERROR_PG,
* FLASH_ERROR_WRP, FLASH_COMPLETE or FLASH_TIMEOUT.
*/
FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data)
{
FLASH_Status status = FLASH_COMPLETE;
__IO uint32_t tmp = 0;
/* Check the parameters */
assert_param(IS_FLASH_ADDRESS(Address));
#ifdef STM32F10X_XL
//................
#else
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation(ProgramTimeout);
if(status == FLASH_COMPLETE)
{
/* if the previous operation is completed, proceed to program the new first half word */
FLASH->CR |= CR_PG_Set;
*(__IO uint16_t*)Address = (uint16_t)Data;
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation(ProgramTimeout);
if(status == FLASH_COMPLETE)
{
/* if the previous operation is completed, proceed to program the new second half word */
tmp = Address + 2; // 这里也可以看出, stm323 是小端法 CPU
*(__IO uint16_t*) tmp = Data >> 16; // 把一个字拆分成两个半字,分两次写入 flash
/* Wait for last operation to be completed */
status = FLASH_WaitForLastOperation(ProgramTimeout);
/* Disable the PG Bit */
FLASH->CR &= CR_PG_Reset;
}
else
{
/* Disable the PG Bit */
FLASH->CR &= CR_PG_Reset;
}
}
#endif /* STM32F10X_XL */
/* Return the Program Status */
return status;
}
(102)例题 1 ,读写内部 flash :

++ 上面没有写入字节的函数,因为太麻烦,改用缓冲区了 。

++

(103) 两个项目工程配置 :

++

(104) 看懂编译信息 :

++

++

++

++

++

(105)例题2 , 读取芯片 ID :

++ 这里也可以查看与验证程序的执行结果,但上面的截图,是截图老师的视频里的 :

(106)

(107)
谢谢