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.

MSP432P401R: Two SPI connections

Part Number: MSP432P401R

Hi, I would like to use "MSP432P401R LaunchPad" for a project.  Can MSP432P401R LaunchPad exchange data with two SPI slaves?

  • Hi Huang!

    Since SPI is a bus, you can virtually connect as many devices as you like to a single USCI module. Every slave normally has it's own chip select, so as long as you can provide one for every device, they all can share the same MISO, MOSI and CLK line. Although a rising number of slaves would require a higher drive strength of the signals, I doubt that you plan to use tens of slaves, do you?

    Additionally the MSP432P401R has eight independent USCI modules that can all do SPI, so you could connect eight different slaves that wouldn't even need to share a module. But the LaunchPad might not have all of them routed out to the headers - please double check the pinout of the board.

    Dennis

  • Hello,

    As Dennis states, you can operate multiple SPI slaves from a single MSP432P401R device as a master.  Each slave would then need its own CS, chip select, pin which would be from any available GPIO.

    As a general answer to your question, yes it does have this capability.  If you have further questions how to implement this, please do not hesitate to ask.

  • Haung,

    Did this answer your question and get you started?  If you need more assistance getting started with SPI, Resource Explorer (Accessable via dev.ti.com or in the view tab on CCS) is a great starting point.  I will be closing this thread soon since I have not heard from you recently, but if you need to re-open and ask more questions about getting this SPI connections to work, please do not hesitate to do so.

  • I am using LaunchPad for testing.  From the pin mapping, it seems that there are three SPI CS available.   Is there a sample codes on how I can program the launchpad to activate the SPI?  Thank you.

  • Huang,

    Yes, there are examples available from www.dev.ti.com in the resource explorer.  The MSP432 examples can be found under SOFTWARE->SIMPLELINK MSP432 SDK -> EXAMPLES.  Here is a one example from that location and it uses the MSP432 as a SPI Master device using a single CS. 

    This resource explorer is also available in CCSv7 under the View tab.

  • Thank you for the very helpful links.

  • You can use any GPIO pin for slave select. There is no need to use STE at all.
  • Could you rephrase this question?  I am not sure I understand the question.

  • I have a follow up question. I have two slaves I would like to connect to a single SPI eUSCI module on the MSP432. One device uses CPOL:0 CPHA:1. The other uses CPOL:1 CPHA:1, or either CPOL:0 or CPHA:0. Can I do this?

  • How to control the SPI clock rate?

  • There are BR0 and BR1 for setting the divider. BR0 is just the integer value, BR1 ist the integer value multiplied by 256. Both added form the divider. Now it depends on the clock source for the module. Example: Clock source is SMCLK at 8MHz and you have BR1 set to 0 and BR0 set to 4. This will result in (8MHz / ((0 x 256) + 4)) = 2MHz. As you can see, the resulting clock speed is always equal or less compared to the input clock speed.

    I hope this also applies to the MSP432 - don't know exactly right now since I do not have any documentation at the moment. Have to check that later. But it will be very similar.

    Dennis
  • Luke, you would need to change the control register (CTLW0) settings for the module to reflect the desired CPOL/CPHA settings each time you switched between devices prior to enabling each slave device. Typically, these settings are configured only once in the beginning of main; you would need to change these parameters each time you switch between devices. Does that make sense?
  • Thank you for the help, Dennis.  Yes, Dennis is right that the BRW register (split into BR0 & BR1 bytes) is the divider value.  There is a BRW macro definition so splitting into 2 separate values BR1/BR0 isn't needed.  UCSSEL sets the source clock and then the bitrate is the source (BRCLK) divided by the BRW word.  This is explained in Section 23.3.6 of the datasheet.

  • Yes, this makes sense John. Sorry for the tangent. I construct the parameters for the spi device and initiate them in main() like in the examples provided. One particular issue im worried about is that I have is that I have one high priority, device, an ADC, that is continuously running and synced with other devices. The Interrupt for the ADC is a comparator, and within this interrupt the Master exchanges data with the Slave ADC. Would the best solution to avoid losing ADC synchronization be to use another interrupt, and within this interrupt briefly change the module to my desired CPOL/CPHA and send the command to the other device (a PGA which requires only a command with no useful returned bytes)?
  • Luke,

    I'm not completely sure if this would be the best approach or not; I am sure it would depend on your specific system.  A lot of variables seem to be needed to know if changing the registers for the SPI will happen quickly enough to capture the data you are looking for in a reasonable way for your system.

    A few thoughts.

    1. If 14 bit resolution is enough, you could look into using the built-in ADC peripheral. (I'm guessing you've considered this already and need more resolution?)

    2. You can test the method you mention here and see what results you have and decide if it works in your application through testing.

    3. My suggestion: Use an additional SPI peripheral in the MSP432. One for each configuration. There are 8 available (4 on eUSCI_A, 4 on eUSCI_B).  Port mapping allows added flexibility if needed.  If you only have 2 slave devices in your system, each SPI module can be dedicated to a single device and no need for running in 4 pin mode since you wouldn't need CS.  Right now you have CLK, MISO, MOSI, CS1, CS2 (5-pins).  This way you would only need CLK1, MISO1, MOSI1, CLK2, MISO2 (5-pins).  You said no MOSI2 for PGA, so total pin count is not affected.

    Let me know what you think and if this seems like an appropriate route for you to take.  Thanks.

  • Mr . Morrison,
    Your suggestion is top notch. Same pin count, two SPI peripherals. I appreciate the answer to my tangent to the original question. You are a true pro!
    Thank you!
  • Huang,

    Have we answered all of your questions?  I thought I saw another question (about switching to a higher rate) in my emails, but it looks like it had been deleted from the forum?  Do you still have further questions?

**Attention** This is a public forum