RTC_AlarmTypeDef RTC_AlarmStructure; RTC_TimeTypeDef time; PWR_RTCAccessCmd(ENABLE); RTC_AlarmCmd(RTC_Alarm_A, DISABLE); RTC_ITConfig(RTC_IT_ALRA,DISABLE ); RTC_AlarmStructure.RTC_AlarmMask =RTC_AlarmMask_None;; time.RTC_Seconds=0; time.RTC_Minutes=0; time.RTC_Hours=0; time.RTC_H12=0; RTC_AlarmStructure.RTC_AlarmTime=time; RTC_SetAlarm(RTC_Format_BCD, RTC_Alarm_A, &RTC_AlarmStructure); RTC_ITConfig(RTC_IT_ALRA, ENABLE); RTC_AlarmCmd(RTC_Alarm_A, DISABLE); PWR_RTCAccessCmd(DISABLE); 调试发现这样修改不了RTC_ALRMAR里面的数值, MSK的值可以改变 但是 DT DU HT HU ST SU修改不了,应该说已经打开RTC保护了呀 另外有没做过STM32L的高手可以请教下,这段时间再弄这个东西 |
STM32L151RDT6 SDIO读写SD卡 FIFO下溢错误,不知是什么原因
STM32L152 RTC唤醒STOP mode问题
STM32L152系列自带LCD驱动段码液晶屏,怎么驱动想要亮的段亮
STM32L151为何FLASH擦除后全是是0x00?
求助!!STM32L151中的RTC唤醒(wake up)中断问题
STM32L152普通I/O模拟SPI驱动W25Q16问题
STM32L152开发板原理图及说明文档
STM32L1系列,如何释放PA15为普通GPIO端口
STM32L151读取W25Q16的ID错误,请帮忙看看是什么原因
STM32L151 STOP模式唤醒程序跑哪儿了
Note:This register can be written in initialization mode only (RTC_ISR/INITF = ‘1’).
This register is write protected. The write access procedure is described in RTC register
write protection on page 511.
现在是这样的
void RTC_AlarmConfig(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
RTC_AlarmTypeDef RTC_AlarmStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RTC_TimeTypeDef time;
/* EXTI configuration */
EXTI_ClearITPendingBit(EXTI_Line17);
EXTI_InitStructure.EXTI_Line = EXTI_Line17;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Enable the RTC Alarm Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
RTC_WriteProtectionCmd(DISABLE);// RTC->WPR = 0xCA; RTC->WPR = 0x53;
RTC_EnterInitMode();//RTC_ISR/INITF = ‘1’
/* Allow access to RTC */
PWR_RTCAccessCmd(ENABLE);
/* Enable the alarmA */
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
/* Set the alarmA Masks */
RTC_AlarmStructure.RTC_AlarmMask =RTC_AlarmMask_DateWeekDay|RTC_AlarmMask_Hours|RTC_AlarmMask_Minutes;
// RTC_AlarmStructure.RTC_AlarmMask =RTC_AlarmMask_None;;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds=5;
RTC_AlarmStructure.RTC_AlarmDateWeekDaySel=RTC_AlarmDateWeekDaySel_Date;//设置为date模式
RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
/* Enable AlarmA interrupt */
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
/* Enable the alarmA */
RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
/* Allow access to RTC */
PWR_RTCAccessCmd(DISABLE);
RTC_WriteProtectionCmd(ENABLE);
}
void RTC_Alarm_IRQHandler(void)
{
if(RTC_GetITStatus(RTC_IT_ALRA) != RESET)
{
/* Clear RTC AlarmA Flags */
RTC_ClearITPendingBit(RTC_IT_ALRA);
printf("alarm\r\n");
}
/* Clear the EXTIL line 17 */
EXTI_ClearITPendingBit(EXTI_Line17);
RTC_ClearFlag(RTC_FLAG_ALRAF);
}
实现了到每分钟第5秒中断
问题又来了,中断清除不了 RTC_FLAG_ALRAF 然后就再也进不了中断了
RTC_WriteProtectionCmd(ENABLE);
RTC被写保护了,
算了,还是去看文档吧,英语不好真累
RTC->WPR = 0xCA;
RTC->WPR = 0x53;
if ((RTC->ISR & RTC_ISR_INITF) == (uint32_t)RESET)
{
/* Set the Initialization mode */
RTC->ISR = (uint32_t)RTC_INIT_MASK;
/* Wait till RTC is in INIT state and if Time out is reached exit */
do
{
initstatus = RTC->ISR & RTC_ISR_INITF;
i++;
} while((i != 1000) && (initstatus == 0x00));
}
RTC->CR &=(uint32_t)~(RTC_CR_ALRAIE);
RTC->ISR &=(uint32_t)~(RTC_ISR_ALRAF);
RTC->ALRMAR=temp;
RTC->CR|=(uint32_t)(RTC_CR_ALRAIE|RTC_CR_ALRAE);
//RTC->TAFCR |= (uint32_t)(RTC_TAFCR_TAMPIE);
RTC->ISR &= (uint32_t)~RTC_ISR_INIT;
RTC->WPR = 0xFE;
RTC->WPR = 0x64;