完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
在学习STM32F0的RTC时,不太清楚AlarmA的中断函数RTC_IRQHandler中每次都要清除EXti_ClearITPendingBit(EXTI_Line17);
要是没有行不行,为什么要这样做?哪位高手给个解释啊? 程序如下: void RTC_IRQHandler(void) { /* Check on the AlarmA flag and on the number of interrupts per Second (60*8) */ if(RTC_GetITStatus(RTC_IT_ALRA) != RESET) { /* ALARM is enabled */ ALARM_Occured = 1; /* Clear RTC AlarmA Flags */ RTC_ClearITPendingBit(RTC_IT_ALRA); } /* Clear the EXTIL line 17 */ EXTI_ClearITPendingBit(EXTI_Line17); } |
|
相关推荐
7个回答
|
|
最后一句是清除挂起位,肯定需要的,不然也不会出来这么个函数。
|
|
|
|
|
|
|
|
lz你好,,可以分享下你RTC闹钟的配置吗?由于没有LSE,所以使用LSI作为时钟源,但是看起来不能正常工作
void RTC_Config(void) { RTC_InitTypeDef RTC_InitStructure; RTC_TimeTypeDef RTC_TimeStruct; /* Enable the PWR clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); printf("999rn",0); /* Allow access to RTC */ PWR_BackupAccessCmd(ENABLE); RCC_LSICmd(ENABLE); while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET) { } /* Select the RTC Clock Source */ RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI); /* Configure the RTC data register and RTC prescaler */ RTC_InitStructure.RTC_AsynchPrediv = 0x7F; RTC_InitStructure.RTC_SynchPrediv = 0xFF; RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; RTC_Init(&RTC_InitStructure); /* Set the time to 00h 00mn 00s AM */ RTC_TimeStruct.RTC_H12 = RTC_H12_AM; RTC_TimeStruct.RTC_Hours = 0x00; RTC_TimeStruct.RTC_Minutes = 0x00; RTC_TimeStruct.RTC_Seconds = 0x00; if(ERROR == RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct)) printf("7rn",0); /* Enable the RTC Clock */ RCC_RTCCLKCmd(ENABLE); /* Wait for RTC APB registers synchronisation */ if(ERROR == RTC_WaitForSynchro()) printf("2rn",0); } /** * @brief Configures the RTC Alarm. * @param None * @retval None */ void RTC_AlarmConfig(void) { EXTI_InitTypeDef EXTI_InitStructure; RTC_AlarmTypeDef RTC_AlarmStructure; NVIC_InitTypeDef NVIC_InitStructure; /* 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_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* Set the alarmA Masks */ RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_All; RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure); /* Set AlarmA subseconds and enable SubSec Alarm : generate 8 interripts per Second */ RTC_AlarmSubSecondConfig(RTC_Alarm_A, 0xFF, RTC_AlarmSubSecondMask_SS14_5); /* Enable AlarmA interrupt */ RTC_ITConfig(RTC_IT_ALRA, ENABLE); /* Enable the alarmA */ RTC_AlarmCmd(RTC_Alarm_A, DISABLE); } |
|
|
|
上面的配置是按照ST的官方例程写的
|
|
|
|
cmh23 发表于 2018-11-29 08:25 用内部时钟需要校准! |
|
|
|
Internal interrupt line 17 Connected to the RTC Alarm event
这里说明了LINE17是RTC alarm中断引起的,所以要清除. |
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
2136 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
1970 浏览 3 评论
4566 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
2116 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
2629 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 03:55 , Processed in 0.836901 second(s), Total 85, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号