开发环境:WIN8.1+ARM_MDK+STM32F030 DISCO
以前清除寄存器都是读写存的方式,但是在cortex-mx中看见有些寄存器是通过硬件设置,写1清除,写0则没效果。
今晚看了discovery的Flash_Program demo发现如下代码:
/* Clear pending flags (if any) */
FLASH_ClearFlag(FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPERR);
void FLASH_ClearFlag(uint32_t FLASH_FLAG)
{
/* Check the parameters */
assert_param(IS_FLASH_CLEAR_FLAG(FLASH_FLAG));
/* Clear the flags */
FLASH->SR = FLASH_FLAG;
}
脑子突然转不过弯来,久久不能想通为什么这样是清除,还觉得是库错了,后来仔细看看手册才恍然大悟,悲剧
------------
Set by hardware when programming a write-protected address of the Flash memory.Reset by writing 1.
--------------------------------
|