Jump to content
Forum sending old emails Read more... ×
Markers

MSP430 problems reading from MMA8451

Recommended Posts

Hi,

I have built an embedded product on a custom pcb that uses an MSP430G2553 communicating with a MMA8451 accellerometer via I2C, and flashing LEDs when certain acceleration events cause interrupts.  The system works reasonably well but I want to add some post-interrupt code to verify the direction and intensity of the acceleration to avoid false positives.

I can read the value in the relevant TRANSIENT_SRC register (0x1E) on the MMA8451 but the system hangs returning from the ISR.  I placed a breakpoint in the closing curly bracket of the ISR, and when I stepped past this breakpoint an Assembler routine called "isr_trap.asm" opens and hangs on line "BIS.W  #(0x0010),SR".  I see from previous posts that this is a trap for "an interrupt [that] occurs that has no ISR assigned."

My register read routine is:

char Receive(char registerAddr)
{
    char receivedByte;
    while (UCB0CTL1 & UCTXSTP);                       // Ensure stop condition got sent
    UCB0CTL1 |= UCTR + UCTXSTT;                     // I2C start condition with UCTR flag for transmit
    while((IFG2 & UCB0TXIFG) == 0);                    //UCB0TXIFG is set immediately
    UCB0TXBUF = registerAddr;                             //write registerAddr in TX buffer
    while((IFG2 & UCB0TXIFG) == 0);                     // wait until TX buffer is empty and transmitted
    UCB0CTL1 &= ~UCTR ;                                      // Clear I2C TX flag for receive
    UCB0CTL1 |= UCTXSTT; //+ UCTXNACK;       // I2C start condition with NACK for single byte reading  
    while (UCB0CTL1 & UCTXSTT);                       // Start condition sent? RXBuffer full?
    UCB0CTL1 |= UCTXSTP;                                    // I2C stop condition
    //while(UCB0RXIFG != (IFG2 & UCB0RXIFG));    //keep checking for recv ready flag
    while((IFG2 & UCB0RXIFG) == 0);                      // wait until TX buffer is empty and transmitted     
    receivedByte = UCB0RXBUF;
    return receivedByte;
}

Can anyone see a issue that is likely to cause my problem? Note that the system works perfectly is I do not read TRANSIENT_SRC.

 

Many thanks, Mark.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×