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/MSP432P401M: SPI Code || MCP23S17

Part Number: MSP432P401M

Tool/software: Code Composer Studio

Hello Team,

I have attached piece of schematics and my SPI code, i tried in many ways but not getting any luck in getting through. Problem is we are unable to communicate with SPI IO expander chip. I would need to help to review the code and let me know for any wrong settings or any other issues.

I am using 48MHz crystal on hardware side. I can provide full schematics if required for deeper analysis. In the schematics DNI indicates, do not install.

Thanks.

- Jagdish G

spi_gpio.txt
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifdef REQUIRED
/* --COPYRIGHT--,BSD
* Copyright (c) 2017, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
/******************************************************************************
* MSP432 SPI - 3-wire Master Incremented Data
*
* This example shows how SPI master talks to SPI slave using 3-wire mode.
* Incrementing data is sent by the master starting at 0x01. Received data is
* expected to be same as the previous transmission. eUSCI RX ISR is used to
* handle communication with the CPU, normally in LPM0. Because all execution
* after LPM0 is in ISRs, initialization waits for DCO to stabilize against
* ACLK.
*
* Note that in this example, EUSCIB0 is used for the SPI port. If the user
* wants to use EUSCIA for SPI operation, they are able to with the same APIs
* with the EUSCI_AX parameters.
*
* ACLK = ~32.768kHz, MCLK = SMCLK = DCO 3MHz
*
* Use with SPI Slave Data Echo code example.
*
* MSP432P401
* -----------------
* | |
* | |
* | |
* | P1.6|-> Data Out (UCB0SIMO)
* | |
* | P1.7|<- Data In (UCB0SOMI)
* | |
* | P1.5|-> Serial Clock Out (UCB0CLK)
*******************************************************************************/
/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Can you determine if the SPI is transmitting at all?  If you cannot then I would recommend starting with a known working example to determine if there is a hardware issue.

    Regards,

    Chris

  • Your schematic shows the SPI being connected to UCA0 but your SPI code is using UCB0.

    0x55 has no meaning as the first byte of a transaction. Per data sheet (20001952c) Fig 3-5, at minimum the high order (hex) digit needs to be 4.

    There are no one-byte transactions, since (per DS sec. 3.3.2) the first byte is a slave-address byte (similar to I2C).
  • Chris,

    Looks like SPI is transmitting, we did captured master data out scope traces. Since we had multiple hardware setup, we tried all to ensure its not single board problem. Firmware engineer did started with example code from beginning but no luck. Slave is not responding.

    -Jagdish g

  • Bruce,

    Since we copied from example code base, we have conditional if statement to jump to UCA0. I will check the registers setting as per your suggestions and feedback. In case if you have any other suggestions, please share.

    -Jagdish g
  • Hello,
    Has any progress been made on this? Looking at the code it appears that the master is configured for 4-wire mode but the signal is described as chip select. I would not recommend using the STE as a CS.

    Regards,
    Chris
  • Chris, Still No luck. So can we go for 3wire mode and make CS permanently low for testing purpose. Will this help us?. Also do you see any other issues on both schematics and code. Pls let me know. thx
  • I would recommend using the three wire mode and then pulling the CS line low before loading the transmit buffer. Be sure that all communication is finished before setting CS high. Note that the transmit ifg indicates that the buffer is empty and NOT that transmission has completed. The transmit data is moved from the buffer to the shift register and then the data is transmitted. Use the receive IFG or the busy flag to determine when to set the CS high.

    Regards,
    Chris
  • I will consider this topic closed, but please feel free to continue this thread if needed or open a related post ('Ask a related question') if you have other inquiries.

    Regards,
    Chris
  • Thanks Chris.

    Will reach you incase of further questions.

**Attention** This is a public forum