Jump to content
43oh

MSP430G2553 Issue: HardwareSerial I/O corrupts SPI I/O


Recommended Posts

See post here: http://forum.43oh.com/topic/3237-energia-library-nordic-nrf24l01-library/?p=28498

 

Energia version: 0101E0009 on MacOS X Snow Leopard.

 

 

Description:

 

When mixing SPI I/O and Serial I/O (e.g. queueing serial debugging messages while doing periodic SPI I/O to a peripheral), extraneous SPI transfers occur concurrently with execution of the IRQ ISRs related to USCI_A0 TX.

 

Offending code found in /Applications/Energia.app/Contents/Resources/Java/hardware/msp430/cores/msp430/usci_isr_handler.c:

__attribute__((interrupt(USCIAB0TX_VECTOR))) 
void USCIAB0TX_ISR(void)
{
        /* USCI_A0 UART interrupt? */
        if (UC0IFG & UCA0TXIFG)
                uart_tx_isr();

        /* USCI_B0 I2C TX RX interrupt. */
        if ((UC0IFG & (UCB0TXIFG | UCB0RXIFG)) != 0)
                i2c_txrx_isr();

}

 

 

The i2c_txrx_isr code will run whenever UCB0TXIFG or UCB0RXIFG is set, which may occur before or after an SPI transfer and in the middle of a multi-byte sequence of SPI I/O.  This is likely to show up as corruption in a race condition pattern.

 

Modification, ensures i2c_txrx_isr is only run if UCB0CTL0's UCMODE is set to 0b11 (I2C mode), ignoring it entirely in SPI mode:

__attribute__((interrupt(USCIAB0TX_VECTOR))) 
void USCIAB0TX_ISR(void)
{
        /* USCI_A0 UART interrupt? */
        if (UC0IFG & UCA0TXIFG)
                uart_tx_isr();

        /* USCI_B0 I2C TX RX interrupt. */
        if ((UCB0CTL0 & UCMODE_3) == UCMODE_3 && (UC0IFG & (UCB0TXIFG | UCB0RXIFG)) != 0)
                i2c_txrx_isr();

}

 

This fixed my bug, and I was able to perform Serial I/O concurrently with SPI I/O to my peripheral (Nordic nRF24L01+)

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.

Guest
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...