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.

msp430F5659: configure I2C and SPI port on USB1, can that work?

Part Number: MSP430F5659

hi 

I have a project, in it to configure the UCB1 port to I2C and SPI in same application, switch between them when need. 

the I2C and SPI used UCB1CTL0 and USB1CTL1, looks same register. when UCSWRST bit resets both I2C and SPI, when enable I2C or SPI using bit UCSWRST,  it enables both I2C and SPI.  is this can work correcly?  I can not make it right, any work around, let me know.

Louis

  • Hello Louis,

    The USCIB module can be used in either I2C or SPI mode. It is possible to change its usage dynamically in an application from the MSP430 standpoint, but typically this is not done. this is mainly due to the fact that the I2C lines require pullup resistors on the physical lines and SPI does not. There could be some issues with pulling SPI data lines up constantly, especially if the attached device cannot drive the lines low.
    Usually if both SPI and I2C are needed within the same application, different USCIs are used.

    I'm not sure what you mean by setting I2C/SPI through USB. Are you talking about sending an USB command that changes settings on the MSP430? If so, this is feasible. you just have to setup RX logic on the USB stack for a specific command, and then change the USCI settings. This is similar to the USB CDC LED On/Off/Flash Example found within the USB Developer's package.
  • type error it is UCB1 it is not USB. it is UCB1CTL0 and UCB1CTL1 two register. to set port on/off

  • I would like to attached screen capture to explain detail, but I cannot find how to attach file.
  • HI JH

    following explain detail screen capture 

    ramWtSpiData  -> use SPI bus to write data in FRAM chip.

    u32ToU8  -> format the write address.  In Watch1 shows, u8TempB[4] has data [0] = 0x00, [1] = 0x04, [2] = 0x00, [3] = 0x00

    at break point SPI bus send out 0x00 0x04 next to send 0x00 again

    Register1 shoe USCI_B1_SPI mode  UCB1TxBUF ___SPI = 0xE1 UCB1RXBUF ___SPI  = 0xFF

    Register 2 show USCI_B1 I2C Mode UCB1TxBUF= 0xE1 UCB1RXBUF  = 0xFF.

    Before calling ramWtSpiData, the code inits the USCI_B1 SPI Mode, the code changes UCSWRST from 1 to 0;  but the code keeps the UCB1CTRL1 I2C mode UCSWRST = 1; but can see, it is 0. 

  • Hello Louis,

    For attaching screen shots or formatting code or other advanced features, please use the "Use rich formatting" button in the bottom right of the reply box.

    I am still not following on what your issue is/ what you want to do. Could you explain a little more about your application and what you are trying to do?
  • The issues are in one application use USCI_B1 for I2c and SPI management, switch between I2C and SPI when need, I2C bus chips, they work good, can see the data on those chips, SPI bus chips, they do not work. The code cannot write data in FRAM or Read back from FRAM, read back all 1s or 0xFF.  Need a solution to make SPI bus chips read/write data.

     

    ramWtSpiData  -> use SPI bus to write data in FRAM chip.

    u32ToU8  -> format the write address.  In Watch1 shows, u8TempB[4] has data [0] = 0x00, [1] = 0x04, [2] = 0x00, [3] = 0x00

    at break point SPI bus send out 0x00 0x04 next to send 0x00 again

    Register1 shoe USCI_B1_SPI mode  UCB1TxBUF ___SPI = 0xE1 UCB1RXBUF ___SPI  = 0xFF

    Register 2 show USCI_B1 I2C Mode UCB1TxBUF= 0xE1 UCB1RXBUF  = 0xFF.

    Before calling ramWtSpiData, the code inits the USCI_B1 SPI Mode, the code changes UCSWRST from 1 to 0;  but the code keeps the UCB1CTRL1 I2C mode UCSWRST = 1; but can see, it is 0.

     

    use Microsoft mode. it cannot attaches the capture.  issues list above.

  • from capture :
    Register1 shoe USCI_B1_SPI mode UCB1TxBUF ___SPI = 0xE1 UCB1RXBUF ___SPI = 0xFF
    do not know write 0x00 0x04 not shows on those registers, but show write 0xe1 and read oxff

    from capture :
    Register 2 show USCI_B1 I2C Mode UCB1TxBUF= 0xE1 UCB1RXBUF = 0xFF.
    the code hold the I2C in reset but it is not and Tx 0xE1 and Rx 0xff, don't know where the data comes
  • Louis,

    As explained before, even though the MSP supports both I2C and SPI on the same module (and thus pins), the hardware requirements between the two are different. I2C requires pull-ups on the HW lines to work, and SPI does not. This is why you are reading 0xFF constantly as the lines are pulled to VCC.

**Attention** This is a public forum