Part Number: MSP430FR4133
Hi,
I am able to run the sample code from blow link. I am using using the Launch pad MSP‑EXP430FR4133.
http://dev.ti.com/tirex/explore/node?node=AIIst5gLtBM7DVuyhd5.8A__IOGqZri__LATEST
Now I want to turn on few LED by pressing the button. I have added below highlighted lines in the sample code provided by TI, but ISR routine not get fired.
If I remove below 2 lines, button interrupt started firing, but RTC interrupt is failed.
PMMCTL0_H = PMMPW_H;
PMMCTL0_L |= PMMREGOFF_L;
Can I able to run the RTC and Port ISR in LPM 3.5 mode? Please help me to resolve it
#include <msp430.h>
#define pos1 4 // Digit A1 - L4
#define pos2 6 // Digit A2 - L6
#define pos3 8 // Digit A3 - L8
#define pos4 10 // Digit A4 - L10
#define pos5 2 // Digit A5 - L2
#define pos6 18 // Digit A6 - L18
const char digit[10] =
{
0xFC, // "0"
0x60, // "1"
0xDB, // "2"
0xF3, // "3"
0x67, // "4"
0xB7, // "5"
0xBF, // "6"
0xE4, // "7"
0xFF, // "8"
0xF7 // "9"
};
volatile unsigned char * Seconds = &BAKMEM0_L; // Store seconds in the backup RAM module
volatile unsigned char * Minutes = &BAKMEM0_H; // Store minutes in the backup RAM module
volatile unsigned char * Hours = &BAKMEM1_L; // Store hours in the backup RAM module
void initGpio(void);
void incrementRtc(void);
int main( void )
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// Configure GPIO
initGpio();
// Initialize XT1 32kHz crystal
P4SEL0 |= BIT1 | BIT2; // set XT1 pin as second function
do
{
CSCTL7 &= ~(XT1OFFG | DCOFFG); // Clear XT1 and DCO fault flag
SFRIFG1 &= ~OFIFG;
} while (SFRIFG1 & OFIFG); // Test oscillator fault flag
if (SYSRSTIV == SYSRSTIV_LPM5WU) // If LPM3.5 wakeup
{
__enable_interrupt(); // The RTC interrupt should trigger now...
}
else
{
// Device powered up from a cold start.
// It configures the device and puts the device into LPM3.5
*Seconds = 0; // Set initial time to 04:30:00
*Minutes = 30;
*Hours = 4;
// Configure RTC
RTCCTL = RTCSS__XT1CLK | RTCIE; // Initialize RTC to use XT1 and enable RTC interrupt
RTCMOD = 32768-1; // Set RTC modulo to 32768 to trigger interrupt each second
// Configure LCD pins
SYSCFG2 |= LCDPCTL; // R13/R23/R33/LCDCAP0/LCDCAP1 pins selected
LCDPCTL0 = 0xFFFF;
LCDPCTL1 = 0x07FF;
LCDPCTL2 = 0x00F0; // L0~L26 & L36~L39 pins selected
LCDCTL0 = LCDSSEL_0 | LCDDIV_7; // flcd ref freq is xtclk
//LCD Operation - Mode 2, internal 3.08v, charge pump 256Hz
LCDVCTL = LCDCPEN | LCDSELVDD | VLCD_8 | (LCDCPFSEL0 | LCDCPFSEL1 | LCDCPFSEL2 | LCDCPFSEL3);
/*
// LCD Operation - Mode 3, internal 3.08v, charge pump 256Hz
LCDVCTL = LCDCPEN | LCDREFEN | VLCD_8 | (LCDCPFSEL0 | LCDCPFSEL1 | LCDCPFSEL2 | LCDCPFSEL3);
*/
LCDMEMCTL |= LCDCLRM; // Clear LCD memory
LCDCSSEL0 = 0x000F; // Configure COMs and SEGs
LCDCSSEL1 = 0x0000; // L0, L1, L2, L3: COM pins
LCDCSSEL2 = 0x0000;
LCDM0 = 0x21; // L0 = COM0, L1 = COM1
LCDM1 = 0x84; // L2 = COM2, L3 = COM3
LCDCTL0 |= LCD4MUX | LCDON; // Turn on LCD, 4-mux selected (LCD4MUX also includes LCDSON)
// Display time
LCDMEM[pos1] = digit[(*Hours) / 10];
LCDMEM[pos2] = digit[(*Hours) % 10];
LCDMEM[pos3] = digit[(*Minutes) / 10];
LCDMEM[pos4] = digit[(*Minutes) % 10];
LCDMEM[pos5] = digit[(*Seconds) / 10];
LCDMEM[pos6] = digit[(*Seconds) % 10];
// Display the 2 colons
LCDMEM[7] = 0x04;
LCDMEM[11] = 0x04;
}
PMMCTL0_H = PMMPW_H; // Open PMM Registers for write
PMMCTL0_L |= PMMREGOFF_L; // and set PMMREGOFF
__bis_SR_register(LPM3_bits | GIE); // Re-enter LPM3.5
__no_operation(); // For debugger
}
#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, RTCIV_RTCIF))
{
case RTCIV_NONE : break;
case RTCIV_RTCIF: break;
default: break;
}
}
void initGpio(void)
{
// Configure all GPIO to Output Low
P1OUT = 0x00;P2OUT = 0x00;P3OUT = 0x00;P4OUT = 0x00;
P5OUT = 0x00;P6OUT = 0x00;P7OUT = 0x00;P8OUT = 0x00;
P1DIR = 0xFF;P2DIR = 0xFF;P3DIR = 0xFF;P4DIR = 0xFF;
P5DIR = 0xFF;P6DIR = 0xFF;P7DIR = 0xFF;P8DIR = 0xFF;
// Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
P1OUT |= BIT7; // Configure P1.3 as pulled-up
P1REN |= BIT7; // P1.3 pull-up register enable
P1IES |= BIT7; // P1.3 Hi/Low edge
P1IE |= BIT7; // P1.3 interrupt enabled
PM5CTL0 &= ~LOCKLPM5;
P1IFG &= ~BIT7;
}
// Port 1 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT1_VECTOR))) Port_1 (void)
#else
#error Compiler not supported!
#endif
{
P1IFG &= ~BIT7;
P1OUT ^= BIT0; // Clear P1.3 IFG
__bic_SR_register_on_exit(LPM3_bits); // Exit LPM3
}
Regards,
Sundar