Objective is simple enable the periodic minute interrupt and service it
involves two files rtc.c with all required routines and main.c which calls it
main.c
#include<stdio.h>
#include<rtc_declarations.h>
int timestamp[7];
void main(void)
{
rtc_init();
rtc_reset();
while(!(1&(RTC_UPDT>>15)))//UPDATE OF TIME MUST BE 0 TO BE READ
{
rtc_read();
printf("%x:%x:%x:%x:%x:%x:%x\n",timestamp[0],timestamp[1],timestamp[2],timestamp[3],timestamp[4],timestamp[5],timestamp[6]);
}
}
rtc_fun.c
#include<rtc_declarations.h>
void rtc_init(void);
void rtc_reset(void);
void rtc_read(void);
void interrupt rtc_isr(void);
extern int timestamp[7];
void rtc_init(void)
{
RTC_CTR=0x01;//enable interrput
RTC_INT=0x02;//enable min periodic interrupt
}
void rtc_read(void)
{//load all msec,...registers in to the structure and return it
//TIME *timestamp=*temp;
timestamp[0] = RTC_MSEC;
timestamp[1] = RTC_SEC;
timestamp[2] = RTC_MIN;
timestamp[3] = RTC_HOUR;
timestamp[4] = RTC_DAY;
timestamp[5] = RTC_MONTH;
timestamp[6] = RTC_YEAR;
}
void rtc_reset(void)
{
int temp;
temp = RTC_CTR;
RTC_CTR =0; // disable interrupt
RTC_MSEC = 0x1006;
RTC_SEC = 0x0005;
RTC_MIN = 0x0020;
RTC_HOUR = 0x0011;
RTC_DAY = 0x0001;
RTC_MONTH = 0x0004;
RTC_YEAR = 0x2013;
//set to april 4 2013 11hrs:20Min:5Sec:1006msec
RTC_UPDT = 0x8000; // update time
while(RTC_UPDT != 0);
RTC_CTR = temp; // recover interrupt
}
void interrupt rtc_isr(void)
{
if(1&(RTC_STAT>>2))
{//min periodic interrupt raised
RTC_STAT&=(~(1<<2));//clear min interrupt
printf("min interrupt serviced");
}
}
Problem :desired function is not achieved why? any mistakes i have done? what could be error? just the rtc registers values are updating and printed on console but never the periodic minute interrupt is serviced
interrupt vector file (Please visit the site to view this file) is been attached and the build was clean with out any errors