I was following the program. but it doesn't work.
Can you help Are You? Where I'm wrong.
/* WakeUp Interrupt Unit(WIU) -> Vectored Interrupt Controllers(VIC) -> IRQ Handler or Vectored Interrupt Controllers(VIC) -> IRQ Handler @ WIU_Line != VIC_Line. ex) VIC : WIU_ITLine - WIU : WIU_Line 0~31 VIC : EXTIT0_ITLine - WIU : WIU_Line 0~7 = USB, RTC, Port 3.[7:2] VIC : EXTIT2_ITLine - WIU : WIU_Line 16~23 = Port 6.[7:0] interrupts VIC : TIM0_ITLine - no use WIU "Device pin description" reference in Datasheet. */
/* Standard includes. */ #include <stdio.h> #include <string.h>
/* Library includes. */ #include "91x_lib.h" #include "91x_wiu.h" #include "91x_rtc.h" #include "91x_it.h"
RTC_TIME t_rtc; RTC_DATE d_rtc;
#define RTC_FREQ 0x8000 //32768 32.768khz
void RTC_Init(void) { WIU_InitTypeDef WIU_InitStructure;
/* Enable WIU clock */ SCU_APBPeriphClockConfig(__RTC, ENABLE); SCU_AHBPeriphReset(__RTC, DISABLE);
// Configure RTC RTC_DeInit(); RTC_ClearFlag(RTC_FLAG_Per); RTC_ITConfig(__RTC, ENABLE); RTC_PeriodicIntConfig(RTC_Per_128Hz); //RTC_TamperConfig(u32 TamperMode, u32 TamperPol);
// Configure RTC cmd //RTC_TamperCmd(FunctionalState NewState); //RTC_AlarmCmd(FunctionalState NewState); //RTC_CalibClockCmd(ENABLE); //RTC_SRAMBattPowerCmd(FunctionalState NewState);
/* Enable the WIU & Clear the WIU line 1 pending bit */ WIU_Cmd(ENABLE ); WIU_ClearITPendingBit(WIU_Line1);
/* Configure interrupt line */ WIU_DeInit(); WIU_StructInit(&WIU_InitStructure); WIU_InitStructure.WIU_Line = WIU_Line1 ; //WIU_Line0 : USB, WIU_Line1 : RTC WIU_Line 2~7 = port 3 . 2:7 WIU_InitStructure.WIU_TriggerEdge = WIU_RisingEdge; // WIU_FallingEdge; WIU_Init(&WIU_InitStructure);
/* Select WIU line 1 as RTC_ITLine interrupt source */ SCU_WakeUpLineConfig(1);
/* Configure the External interrupt group 0 priority as FIQ interrupt */ VIC_Config(RTC_ITLine, VIC_IRQ, 0);// WIU_ITLine, VIC_IRQ, VIC_FIQ
/* Enable the RTC interrupt */ VIC_ITCmd(RTC_ITLine, ENABLE);
//TimeInit(); //2013.01.01.00:00:00 }
void RTC_IRQHandler(void) { RTC_PeriodicIntConfig (RTC_Per_DISABLE); RTC_ClearFlag (RTC_FLAG_Per);
xPrintf("WIU ON\r\n"); if (WIU_GetITStatus(WIU_Line1)==SET) {
RTC_GetDate(BINARY, &d_rtc); RTC_GetTime(BINARY, &t_rtc);
xPrintf(" %04d %02d %02d %02d:%02d:%02d \r\n", d_rtc.century*100 + d_rtc.year, d_rtc.month, d_rtc.day, t_rtc.hours, t_rtc.minutes, t_rtc.seconds );
WIU_ClearITPendingBit(WIU_Line1); } RTC_PeriodicIntConfig (RTC_Per_128Hz); }
ps. i worked the program use task.
void vRTCTasks( unsigned portBASE_TYPE uxPriority) { RTC_Init(); xTaskCreate( vRTCtesttask, ( signed char * ) "RTC_Test", configMINIMAL_STACK_SIZE +900, NULL, uxPriority, ( xTaskHandle * ) NULL ); } /*-----------------------------------------------------------*/ static portTASK_FUNCTION( vRTCtesttask, pvParameters ) { int ncnt=0; ( void ) pvParameters;
while(1) { if(ncnt>250) { RTC_GetDate(BINARY, &d_rtc); RTC_GetTime(BINARY, &t_rtc); //Ts_a=t_rtc.seconds; // Get the date again if the current time is 00:00:00 (Midnight)
if ((t_rtc.hours == 0) && (t_rtc.minutes == 0) && (t_rtc.seconds == 0)) RTC_GetDate(BINARY, &d_rtc); //if(Ts_b!=Ts_a) //{ xPrintf(" %04d %02d %02d %02d:%02d:%02d \r\n", d_rtc.century*100 + d_rtc.year, d_rtc.month, d_rtc.day, t_rtc.hours, t_rtc.minutes, t_rtc.seconds ); //} //Ts_b=Ts_a; ncnt=0; } vTaskDelay(2); ncnt++; } }