리셋버튼
Bit 26 PINRSTF:
PIN reset flag Set by hardware when a reset from the NRST pin occurs. // NRST 핀으로부터 hw 적으로 리셋플래그
It is cleared by writing to the RMVF
// RMVF 로부터 writing 되어야 값초기화
bit. 0: No reset from NRST pin occurred 1: Reset from NRST pin occurred
BKP introduction
The backup registers are forty two 16-bit registers for storing 84 bytes of user application data.
They are implemented in the backup domain that remains powered on by VBAT when the VDD power is switched off. They are not reset when the device wakes up from Standby mode or by a system reset or power reset.
After reset, access to the Backup registers and RTC is disabled
16비트 레지스터 > 84바이트 백업
Vdd power off 더라도 데이터가 남아있음
리셋후 > 접근 불가
. To enable access to the Backup registers and the RTC,
>by setting the PWREN and BKPEN bits in the RCC_APB1ENR register : 레지스터 설정으로
> enable the power and backup interface clocks : enable 하게함
+
set the DBP bit in the Power control register (PWR_CR)
> PWR_CR 내에 DBP bit set
>> RTC 활성화
1. RCC : LSE enable
2. Timer : RTC
3. LSE 로 클럭 config
void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
{
if(rtcHandle->Instance==RTC)
{
/* USER CODE BEGIN RTC_MspInit 0 */
/* USER CODE END RTC_MspInit 0 */
HAL_PWR_EnableBkUpAccess();
/* Enable BKP CLK enable for backup registers */
__HAL_RCC_BKP_CLK_ENABLE(); // BKP
/* RTC clock enable */
__HAL_RCC_RTC_ENABLE();
/* USER CODE BEGIN RTC_MspInit 1 */
/* USER CODE END RTC_MspInit 1 */
}
>>
void HAL_PWR_EnableBkUpAccess(void)
{
/* Enable access to RTC and backup registers */
*(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE; // DBP > enable
}
#define __HAL_RCC_BKP_CLK_ENABLE() do { \
__IO uint32_t tmpreg; \
SET_BIT(RCC->APB1ENR, RCC_APB1ENR_BKPEN);\
/* Delay after an RCC peripheral clock enabling */\
tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_BKPEN);\
UNUSED(tmpreg); \
} while(0U)
// BKPEN bits in the RCC_APB1ENR 이용
hal_config, 클럭, gpio 업데이트 해줘야함