Jump to content

MSP430 problems reading from MMA8451

Recommended Posts


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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...