在线时间0 小时
UID252090
ST金币0
蝴蝶豆0
注册时间2010-12-5
新手上路
- 最后登录
- 2020-12-7
|
楼主 |
发表于 2012-2-23 14:53:49
|
显示全部楼层
a0a.1 0b0c
RE:需要stm32f207--RTC的ALARM中断代码
代码如下:
void wuRtc_Gpio_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14|GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
//GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
//GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
//GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void wuRtc_Nvic_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void RtcIntruptInit(void)
{
RTC_AlarmTypeDef RTC_AlarmStructure;
// RTC_AlarmTypeDef RTC_AlarmStruct;
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
RTC_AlarmCmd(RTC_Alarm_B, DISABLE);
// RTC_AlarmStructInit(&RTC_AlarmStruct);
RTC_AlarmStructure.RTC_AlarmDateWeekDay = 1;
RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_All;//RTC_AlarmMask_DateWeekDay|RTC_AlarmMask_Hours|RTC_AlarmMask_Minutes;
RTC_AlarmStructure.RTC_AlarmTime.RTC_H12 = 0;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = 0;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = 0;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = 0x01;
RTC_SetAlarm(RTC_Format_BCD, RTC_Alarm_A, &RTC_AlarmStructure);
RTC_SetAlarm(RTC_Format_BCD, RTC_Alarm_B, &RTC_AlarmStructure);
RTC_WaitForSynchro();
RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
RTC_AlarmCmd(RTC_Alarm_B, ENABLE);
}
void wuRtc_Configuration(void)
{
RTC_InitTypeDef RTC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
PWR_BackupAccessCmd(ENABLE);
wuRtc_Gpio_Init(); //osc32初始化
/* 将外设BKP的全部寄存器重设为缺省值 */
//RCC_BackupResetCmd(ENABLE);
//RCC_BackupResetCmd(DISABLE);
/* 使能LSE(外部32.768KHz低速晶振)*/
RCC_LSEConfig(RCC_LSE_ON);
/* 等待外部晶振震荡稳定输出 */
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET){}
/*使用外部32.768KHz晶振作为RTC时钟 */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
RTC_WaitForSynchro();
/* 使能 RTC 的时钟供给 */
RCC_RTCCLKCmd(ENABLE);
RTC_WaitForSynchro();
//RTC_DeInit();
RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
RTC_InitStructure.RTC_SynchPrediv = 0xFF;
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
RTC_Init(&RTC_InitStructure);
RTC_WaitForSynchro();
Set10Sinit();
wvRtcDateTimeSet();
RTC_WaitForSynchro();
// wuExtiLineCfg();/////////////////////////////..........TEST.....................////////////////////////
wuRtc_Nvic_Configuration();
RtcIntruptInit();
RTC_WaitForSynchro();
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
RTC_ITConfig(RTC_IT_ALRB, ENABLE);
RTC_WaitForSynchro();
/* 使能 RTC 的时钟供给 */
//RCC_RTCCLKCmd(ENABLE);
} |
|