΢²¨EDAÍø£¬¼ûÖ¤Ñз¢¹¤³ÌʦµÄ³É³¤£¡
Ê×Ò³ > Ó²¼þÉè¼Æ > ǶÈëʽÉè¼Æ > dz̸STM32F10XоƬRTCʵʱʱÖÓ

dz̸STM32F10XоƬRTCʵʱʱÖÓ

ʱ¼ä£º11-11 À´Ô´£º»¥ÁªÍø µã»÷£º

upConfig(up_1);

NVIC_InitStructure.NVIC_IRQChannel =RTCAlarm_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

/*ÉèÖÃÄÖÖÓÖжÏÓÅÏȼ¶¸ßÓÚÈ«¾ÖÖжÏ*/

NVIC_InitStructure.NVIC_IRQChannel =RTC_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

}

void RTC_Configuration(void)

{

RCC_APB1PeriphClockCmd(RCC_APB1Periph_BKP | RCC_APB1Periph_PWR,ENABLE);

PWR_BackupAccessCmd(ENABLE);

BKP_DeInit();

RCC_LSICmd(ENABLE);

while(RESET == RCC_GetFlagStatus(RCC_FLAG_LSIRDY))

{

}

RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

RCC_RTCCLKCmd(ENABLE);

RTC_WaitForSynchro();

RTC_WaitForLastTask();

RTC_ITConfig(RTC_IT_ALR,ENABLE);

RTC_ITConfig(RTC_IT_SEC,ENABLE);

RTC_SetPrescaler(6000);

RTC_WaitForLastTask();

RTC_SetAlarm(29);

RTC_WaitForLastTask();

BKP_TamperPinCmd(DISABLE);

BKP_RTCOutputConfig(BKP_RTCOutputSource_Second);

}

void EXTI_Configuration(void)

{

EXTI_InitTypeDef EXTI_InitStructure;

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);

}

/*Öжϴ¦Àíº¯Êý*/

void RTC_IRQHandler(void)

{

if(SET == RTC_GetITStatus(RTC_IT_SEC))

{

RTC_ClearITPendingBit(RTC_IT_SEC);

GPIO_WriteBit(GPIOB,GPIO_Pin_13,(BitAction)(1-GPIO_ReadOutputDataBit(GPIOB,GPIO_Pin_13)));

}

}

void RTCAlarm_IRQHandler(void)

{

if(SET == RTC_GetFlagStatus(RTC_IT_ALR))

{

RTC_ClearFlag(RTC_IT_ALR); /*Çå³ýÖжϱê־룬°üÀ¨ÍⲿÖжÏÏß±êÖ¾*/

if(EXTI_GetITStatus(EXTI_Line17));

{

EXTI_ClearITPendingBit(EXTI_Line17);

GPIO_WriteBit(GPIOB,GPIO_Pin_8,(BitAction)(0));

}

}

}

Copyright © 2017-2020 ΢²¨EDAÍø °æȨËùÓÐ

ÍøÕ¾µØͼ

Top