spirilis 1,265 Posted January 25, 2013 Share Posted January 25, 2013 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+) energia and calinp 2 Quote Link to post Share on other sites
spirilis 1,265 Posted January 25, 2013 Author Share Posted January 25, 2013 Update: A cursory glance at the EUSCI code for the FraunchPad leads me to believe this bug does not affect it, just the Value Line USCI chips (G2xx3). Quote Link to post Share on other sites
spirilis 1,265 Posted January 27, 2013 Author Share Posted January 27, 2013 Rick posted this on the github issues... https://github.com/energia/Energia/issues/179 I'll be sure to use that github issue system next time Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.