Hello,
I am currently working on following code. But I couldn't read the RTCSEC. Also when I debug it, I found that CPU is not reaching ISR. I want to send RTC registers on UART.
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
UCS_config(); // Clock Source system
/***************RTC Configuration with Calender Mode*********************/
RTCCTL0_H = RTCKEY_H; // Unlock RTC_C module
RTCCTL0_L |= RTCTEVIE | RTCAIE | RTCRDYIE; // Enable RTC time event, alarm event,
// read ready interrupt
RTCCTL1 |= RTCBCD | RTCHOLD; // RTC enable BCD mode, RTC hold
RTCYEAR = 0x2015; // Year 2015->0x2015
RTCMON = 0x08; // Month August->0x08
RTCDAY = 0x28; // Day 28th->0x28
RTCDOW = 0x05; // Day of week Friday-> 0x05
RTCHOUR = 0x24; // Hour from 24 Hour Mode
RTCMIN = 0x59; // Minute
RTCSEC = 0x55; // Seconds
/*****Alarm Registers*****/
RTCADOWDAY = 0x3; // RTC Day of week alarm = 0x2
RTCADAY = 0x22; // RTC Day Alarm = 0x22
RTCAHOUR = 0x23; // RTC Hour Alarm
RTCAMIN = 0x45; // RTC Minute Alarm
RTCCTL1 &= ~(RTCHOLD); // Start RTC calendar mode
RTCCTL0_H = 0; // Lock RTC_C module
P1DIR &= ~BIT6;
P1OUT |= BIT6;
eUSCI_A0_UART_config();
__bis_SR_register(GIE);
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt
void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
switch (__even_in_range(UCA0IV, 8))
{
case USCI_NONE:
break; // No interrupt
case USCI_UART_UCRXIFG: // RXIFG
break;
case USCI_UART_UCTXIFG:
code for send data on UART....
break; // TXIFG
case USCI_UART_UCSTTIFG:
break; // TTIFG
case USCI_UART_UCTXCPTIFG:
break; // TXCPTIFG
default: break;
}
}
void eUSCI_A0_UART_config(void)
{
// Setup P3.0 UCA0RXD, P3.1 UCA0TXD
P3SEL0 |= BIT0 | BIT1; // Set P3.0, P3.1 to non-IO
P3DIR |= BIT0 | BIT1; // Enable UCA0RXD, UCA0TXD
// Setup eUSCI_A0
UCA0CTLW0 |= UCSWRST; // **Put state machine in reset**
UCA0CTLW0 |= UCSSEL_1; // CLK = ACLK
UCA0BRW=0x0003; // Clock Prescaler Setting baud-rate 32kHz/9600=3.41 (see User's Guide)
UCA0MCTLW = 0x5300; // Modulation UCBRSx=0x53, UCBRFx=0
UCA0CTLW0 &= ~UCSWRST; // **Initialize USCI state machine**
UCA0IE |= UCTXIE|UCRXIE; // Enable USCI_A0 RX/TX interrupt
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=RTC_VECTOR
__interrupt void rtc_isr(void)
//#elif defined(__GNUC__)
//void __attribute__ ((interrupt(RTC_VECTOR))) rtc_isr (void)
//#else
//#error Compiler not supported!
//#endif
{
switch (__even_in_range(RTCIV, 16))
{
case RTCIV_NONE: // No interrupts
break;
case RTCIV_RTCOFIFG: // RTCOFIFG
break;
case RTCIV_RTCRDYIFG: // RTCRDYIFG
{
volatile int sec=RTCSEC;
P1OUT ^= 0x40; // Toggles P1.6 every second
}
break;
case RTCIV_RTCTEVIFG: // RTCEVIFG
__no_operation(); // Interrupts every minute
break;
case RTCIV_RTCAIFG: // RTCAIFG
__no_operation(); // Interrupts every alarm event
break;
case RTCIV_RT0PSIFG: // RT0PSIFG
break;
case RTCIV_RT1PSIFG: // RT1PSIFG
break;
// case 14: break; // Reserved
case 16: break; // Reserved
default: break;
}
}
Please kindly resolve this issue. Is it because I have included two ISRs?
Thank you.
Abhi