main.c文件:
#include "71x_lib.h"
/* Define the RTC prescaler 0x8000 to have 1 second basic clock */ #define RTC_Prescaler 32768
int main (void) { RTC_ITConfig(RTC_GIT | RTC_SIT | RTC_AIT, DISABLE ); // Disable Second and Alarm Interrupt
RTC_FlagClear ( RTC_OWIR ); RTC_FlagClear ( RTC_AIR ); RTC_FlagClear ( RTC_SIR ); RTC_FlagClear ( RTC_GIR ); // Clear Pending Flags
RTC_PrescalerConfig ( RTC_Prescaler ); // Configure RTC prescaler RTC_CounterConfig (0x00); // RTC_ClearCounter(); RTC_AlarmConfig(RTC_CounterValue() + 20); RTC_ITConfig(RTC_GIT | RTC_SIT | RTC_AIT, ENABLE ); // Enable Second and Alarm Interrupt
EIC_IRQChannelConfig( RTC_IRQChannel, ENABLE ); // Enable RTC IRQ channel EIC_IRQChannelPriorityConfig( RTC_IRQChannel, 1); EIC_IRQConfig( ENABLE ); GPIO_Config (GPIO0, 0x2C, GPIO_OUT_PP); // Configure Port 0 pins GPIO0->PD = 0x0000;
while (1); }
71x_it.c文件中的 void RTC_IRQHandler(void) { #ifdef _RTC if ( RTC_FlagStatus ( RTC_SIR ) == SET ) { RTC_FlagClear ( RTC_SIR ); // Clear the SIR & GIR RTC flags GPIO_BitWrite(GPIO0, 2, ~GPIO_BitRead(GPIO0, 2)); }
if ( RTC_FlagStatus ( RTC_AIR ) == SET ) { RTC_FlagClear ( RTC_AIR ); // Clear the SIR & GIR RTC flags RTC_AlarmConfig(RTC_CounterValue() + 20); GPIO_BitWrite(GPIO0, 3, ~GPIO_BitRead(GPIO0, 3)); }
RTC_FlagClear ( RTC_GIR ); #endif }
71x_conf.h文件
#define RCCU_Main_Osc 4000000
/* Comment the lines below corresponding to unwanted peripherals */ #define _EIC
#define _GPIO #define _GPIO0 /* #define _GPIO1 */ /* #define _GPIO2 */
#define _RTC
你可以对照这个代码比较一下,判别你的问题在哪里。
|