This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
#ifndef RTC_H_
#define RTC_H_
#define MINUTE RTCMIN
#define SECOND RTCSEC
#define HOUR RTCHOUR
#define DAY RTCDAY
#define MONTH RTCMON
#define YEAR_1 RTCYEARL
#define YEAR_2 RTCYEARH
#define CAL_CLK_MOD RTCMODE
#define BCD RTCBCD
#define RTC_TIMER RTCHOLD
#define CAL_MOD RTCTEV_0
#define ALARM_1HR RTCAMINHR
/*Function Declaration*/
void init_rtc();
/*Extern variable Declaration*/
extern unsigned char bcd_value[12];
#endif /*RTC_H_*/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/*
* Filename : rtc.c
* Function :This File has rtc related functionality
*/
#include "rtc.h"
char SEC[1];
int RTC_FLAG ;
void init_rtc(){
halLcdClearScreen();
WDTCTL = WDTPW+WDTHOLD; //STOP WATCHDOG TIMER
RTCCTL01 = CAL_CLK_MOD + BCD + CAL_MOD + RTC_TIMER ; //BCD select,Minute Changed,calender mode
P1OUT |= 0x01;
P1DIR |= 0x01;
MINUTE = 0X3 ; //bcd_val[];
SECOND = 0X4 ; // bcd_val[];
DAY = 0X5 ; // bcd_val[] ;
MONTH = 0X7 ; //bcd_val[];
YEAR_1 = 0X20 ; //bcd_val[];
YEAR_2 = 0X12 ;
//bcd_val[];
//ALARM_1HR = 0x1; //bcd_val[];
RTCCTL01 &= ~RTC_TIMER;
//RTCCTL0 |= RTCRDYIE + RTCTEVIE+ RTCTEVIFG;
RTCCTL0 |= RTCRDYIE+RTCTEVIE ;
__bis_SR_register(LPM3_bits + GIE);
while (!(RTCCTL01&RTCRDY)){
if(RTC_FLAG == 1){
P1OUT ^= 0x02; } //toggling of LED
SEC[0] = RTCSEC ;
RTC_FLAG = 0;
}
halLcdPrint(SEC ,OVERWRITE_TEXT);
halLcdCursor(); //Enable interrupt
}
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR(void)
{
switch(__even_in_range(RTCIV,4))
{
case 0: break; // No interrupts
case 2: RTC_FLAG = 1;
break; // RTCRDYIFG
case 4: break; // RTCEVIFG
//case 6: //routine for sending rtc time & bat status on uart
// while (!(RTCCTL01&RTCRDY)){
//alarm_time = ALARM_1HR; break;
// RTCAIFG : User alarm
//case 8: break; // RT0PSIFG
//case 10: break; // RT1PSIFG
//case 12: break; // Reserved
//case 14: break; // Reserved
//case 16: break; // Reserved
default: break;
// __bic_SR_register_on_exit(LPM3_bits);
}
//RTCCTL0 &= ~RTCRDYIFG;
}
This is my RTC CODE in calendar mode i wnt to read value of RTCSEC Register continously..So what else i have to do in my code...I am working on MSP430F5438 .
**Attention** This is a public forum