도와주세요!!
글 수 15,339
2013.11.14 09:54:24 (*.103.3.9)
17488
/*
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);
}
위와 같이 테스트를 해보았는데 되질 않네요.
rtc가 제대로 돌아가냐고 물어보시면
RTC_GetDate(BINARY, &d_rtc);
RTC_GetTime(BINARY, &t_rtc);
//RTC_a= t_rtc.seconds;
//if(RTC_b!=RTC_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 );
//}
//RTC_b= RTC_a;
부분만 따로 분리해서 task로 돌렸을 때는 돌아갔습니다.
(그때는 RTC_ITConfig(__RTC, ENABLE); Disable로 놓고 그 아래는 전부 주석 처리했습니다. 주석은 테스크로 돌릴때 추가한 부분...저러면 초단위로 시리얼로 데이터가 뿌려지게 되죠.)
제가 원하는건 인터럽트로 돌렸을 때 제대로 나오게 하고 싶습니다.(몇초마다 나오는지 궁금한 것도 있구요.)
제 생각으로는 RTC 깨우고 나서 WIU도 깨우고 VIC 깨우고 라고 생각하고 있었습니다만...
제가 뭘 틀렸는지 혹시 알고 계신분 있으신가요? keil 이나 여기저기 돌아다녀 봐도
그냥 task나 main에 바로 사용한 예제 말고는 인터럽트 사용한 것은 없더군요...
답변 주시면 감사하겠습니다.