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.

CCS/MSP430F5529: Can SPI have SIMO and SOMI on same pin

Part Number: MSP430F5529


Tool/software: Code Composer Studio

                             |  eCOM LSM303AGR   |

 |-----P3.5---->|CS_ACC    Pin 2    |

 |-----P3.4---->|CS_MAG    Pin 3    |

 |-----P3.3---->|SDI/O     Pin 4    |

|-----P2.7---->|SCLK      Pin 1    |

 |<----P2.6-----|INT_2_ACC Pin 11   |

 |<----P2.5-----|INT_1_ACC Pin 12   |

 |<----P2.0-----|INT_MAG   Pin 7    | 

 Is it possible to initialize the SPI for an interface to the eCom

when SIMO and SOMI are both on the same pin?

Only one CS can be active.

I always get 0xFF in the UCA0RXBUF

 

uint8_t eComACC_ReadReg(uint8_t RegNum) {

   Reg = (RegNum & 0x3F);

   Reg |= 0x80;                  // Turn on read, Turn off the multiple data bit

   P3OUT &= ~BIT5;                 // Select acceleration sensor

   Result = UCA0RXBUF;             // Read RX buffer just to clear interrupt flag

   while (!(UCA0IFG & UCTXIFG));   // Wait until ready to write

   UCA0TXBUF = Reg;               // Write Address to TX buffer

   while (!(UCA0IFG & UCRXIFG));   // Wait until new data was written into RX buffer

   Result1 = UCA0RXBUF;             // Read RX buffer just to clear interrupt flag

   while (!(UCA0IFG & UCTXIFG));   // Wait until ready to write

   UCA0TXBUF = 0x00;               // Write dummy data to TX buffer

   while (!(UCA0IFG & UCRXIFG));   // Wait until new data was written into RX buffer

   Result2 = UCA0RXBUF;             // Read RX buffer

   while (UCA0STAT & UCBUSY);     // Wait until USCI_A0 state machine is no longer busy

   P3OUT |= BIT5;

   return Result2;                 // Return new data from RX buffer

}

void     eComACC_WriteReg(uint8_t RegNum, uint8_t AccData) {

   RegNum &= 0x3F;                 // Set for write, Turn off the multiple write bit

   P3OUT &= ~BIT5;                 // Select acceleration sensor

   Result = UCA0RXBUF;             // Read RX buffer just to clear interrupt flag

   while (!(UCA0IFG & UCTXIFG));   // Wait until ready to write

   UCA0TXBUF = RegNum;             // Write Reg to TX buffer

   while (!(UCA0IFG & UCRXIFG));   // Wait until new data was written into RX buffer

   Result = UCA0RXBUF;             // Read RX buffer just to clear interrupt flag

   while (!(UCA0IFG & UCTXIFG));   // Wait until ready to write

   UCA0TXBUF = AccData;           // Write data to TX buffer

   while (!(UCA0IFG & UCRXIFG));   // Wait until new data was written into RX buffer

   Result = UCA0RXBUF;             // Read RX buffer

   while (UCA0STAT & UCBUSY);     // Wait until USCI_A0 state machine is no longer busy

   P3OUT |= BIT5;

}

  • Hello Jerry,

    I was looking at the datasheet of the LSM303AGR and it looks like the device have SDI and SDO at the same pin. I dont think the MSP430F5529 support that configuration since one is the output pin and another is the input pin.
    However, I think you can change to I2C communication.
    Or, you can connect the LSM303AGR SDO/SDI to both MSP430F5529 SIMO and SOMI pins and after the MSP430F5529 send the address you will have to manually hold the CLK and switch the SIMO to input pin before the LSM303AGR start to send.

    Thanks,
    Yiding
  • You thought I2C could be used. Have found no I2C application for SOMI and SIMO on same pin. Does anyone have I2C code that will do this?
  • Hello Jerry,

    For I2C communication, you only need two lines which are serial clock line (SCL) and the serial data line (SDA). The device you are trying to use LSM303AGR and MSP430F5529 both support I2C communication so you could just use I2C to communicate between these two devices.

    Thanks,

    Yiding

**Attention** This is a public forum