int main(void) { __bis_SR_register(GIE); MCUInit(); I2C_masterInit(); TimerInit(); I2C_enable(); //TA0CCTL1 |= CCIE; TA1CCTL1 |= CCIE; while (1) { } }
void main (void) { //Stop WDT WDT_hold(__MSP430_BASEADDRESS_WDT_A__); //Assign I2C pins to USCI_B0 GPIO_setAsPeripheralModuleFunctionInputPin(__MSP430_BASEADDRESS_PORT3_R__, GPIO_PORT_P3, GPIO_PIN1 + GPIO_PIN2 ); //Initialize Master I2C_masterInit(__MSP430_BASEADDRESS_USCI_B0__, I2C_CLOCKSOURCE_SMCLK, UCS_getSMCLK(__MSP430_BASEADDRESS_UCS__), I2C_SET_DATA_RATE_400KBPS ); //Specify slave address I2C_setSlaveAddress(__MSP430_BASEADDRESS_USCI_B0__, SLAVE_ADDRESS ); //Set Master in receive mode I2C_setMode(__MSP430_BASEADDRESS_USCI_B0__, I2C_RECEIVE_MODE ); //Enable I2C Module to start operations I2C_enable(__MSP430_BASEADDRESS_USCI_B0__); //Enable master Receive interrupt I2C_enableInterrupt(__MSP430_BASEADDRESS_USCI_B0__, I2C_RECEIVE_INTERRUPT ); while (1) { //Initiate command to receive a single character from Slave I2C_masterSingleReceiveStart(__MSP430_BASEADDRESS_USCI_B0__); //Enter low power mode 0 with interrupts enabled. //Wait until character is received. __bis_SR_register(LPM0_bits + GIE); __no_operation(); } }