Hi all,
I currently have a program that uses an MSP430F2012 (master) to communicate to a slave device by USI SPI. After getting an init(); function working, I tried to add extra interrupt handlers (the USI SPI communication requires interrupts for the USI count), however it never seemed to go into the interrupt. This is what I have:
void setup_usi_spi_master(void)
{
P1DIR |= CS; // Set P1.2 to output direction
P1OUT |= CS;
USICTL0 |= USIPE5+USIPE6+USIPE7+USIMST + USIOE; // Port, SPI master
USICTL1 |= USIIE; // Counter interrupt, flag remains set
USICKCTL = USIDIV_0 + USISSEL_2;// + USICKPL; // To change clk from present SCLK (was originally USIDIV_4 (/16 SMCLK). 7
USICTL1 |= USICKPH;
USICNT |= USI16B;
USICTL0 &= ~USISWRST;
__enable_interrupt();
}
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
setup_usi_spi_master();
__bis_SR_register(LPM0_bits + GIE);
init();
}
After setting up the usi spi master, I attempt to go into my low power mode (infinitely I'm assuming, I didn't set up interrupt handler enablers yet). However for some reason, the program insists on going into the init() function. When i take out the highlighted line above for my setup function, my program does what I expect, never reaching the init(); function do to being in the low power mode waiting for an interrupt which will never happen. Can someone explain to me why this is and if there is a way to fix it? I do need that line in my code for writes and reads to occur properly, but I also need to be able to go into a different low power mode when necessary as well. Any help would be greatly appreciated.
Thanks,
Matt