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.
Hi,
"But when i am waiting for interrupt from accelerometer to msp on GPIO pin(port2.1), interrupt flag is not getting set."
can u pls tell more clear about how, exactly u set the msp GPIO pin to get the interrupt/
if possible pls paste the code
Hi dileep,
are you shure your settings for P2.1 were correct? The code below is taken from a TI example for this sub-series, so you can ignore the LPM4 code.
#include <msp430x47x4.h>
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
P5DIR |= BIT1; // P5.1 output
P1IE |= BIT4; // P1.4 Interrupt enabled
P1IES |= BIT4; // P1.4 hi/low edge
P1IFG &= ~BIT4; // P1.4 IFG Cleared
_BIS_SR(LPM4_bits + GIE); // LPM4, enable interrupts
}
// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port1_ISR (void)
{
P5OUT ^= BIT1; // P5.1 = toggle
P1IFG &= ~BIT4; // P1.4 IFG Cleared
}
So, pls verify your settings for P2IE, P2IES and P2IFG registers!
Rgds
aBUGSworstnightmare
I am using accelerometer MMA8453 which is connected to the MSP430G2231 via I2C bus. I can initialize and get ack from the MMA8453. But I am not able to read the register from MMA8453. I am using code from SLAA 386A modify just to read the register of MMA8453. Below are my code compile by IAR and assembler included USI_I2CMaster.S43
#include <msp430G2231.h>
#include "USI_I2CMaster.h"
unsigned char TxData[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
unsigned char RxData[16];
int j,i;
int StatusCallback(unsigned char c);
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // disable Watchdog
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
{
while(1); // If calibration constants erased
// do not load, trap CPU!!
}
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1DIR |= 0x01;
P1OUT = 0;
// Initialize USI module, clock ~ SMCLK/128
TI_USI_I2C_MasterInit(USIDIV_7+USISSEL_3+USICKPL, StatusCallback);
/* Acknowledge polling function - LED blinks continuously until slave device
provides an ACK
TI_USI_I2CSelect(unsigned char SlaveAddress) */
while(TI_USI_I2CSelect(0x1D))
{
P1OUT ^= 0x01; // Toggle LED
for (i = 0; i < 0x3000; i++); // Delay
}
P1OUT =0; // Slave acknowledged, LED off
/*Transmit data to the slave MSP430 device
TI_USI_I2CWrite(SlaveAddress, Length, Multi, TxData) */
/* __disable_interrupt();
TI_USI_I2CWrite(0x1D, 5, 0,TxData);
__bis_SR_register(LPM0_bits + GIE);*/
/*Read data from the slave MSP430 device
TI_USI_I2CRead(SlaveAddress, Length, Multi, RxData) */
__disable_interrupt();
TI_USI_I2CRead(0x1D, 4, 1,RxData);
__bis_SR_register(LPM0_bits + GIE);
while(1); // program ends here
}
int StatusCallback(unsigned char c)
{
return TI_USI_EXIT_LPM; // exit active for next transfer
}
**Attention** This is a public forum