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.

MSP430F5438A: MSP430F5438A: MSP430ware SPI example project usci_a_spi_ex1_master sets the Slave in Master Out and SPI CLock as Input

Part Number: MSP430F5438A

Hi,

I am using MSP430F5438A  on MSP-TS430PZ5x100 target development board.

In the example project usci_a_spi_ex1_master, I found that SPI is used in 3 wire mode and I have verified that it's working.

What I failed to understand is why the respective GPIOs for Slave in Master Out and SPI clock are set as Input Pin, when clearly they should be set as Output pin.

Below is snippet from the code:

GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P3,
GPIO_PIN5 + GPIO_PIN4 + GPIO_PIN0
);

Thanks and Regards,

Ankit

  • When the pins are connected to the USCI peripheral module, then the direction bits are "don't care", and the direction is actually controlled directly by the module. (This is required for bidirectional I²C to work.)

    If you do not want to confuse readers of your code, nothing prevents you from setting the 'correct' direction …

  • Hi Clemens,

    Thanks for your reply. I have modified the example code as follows, I am facing another problem:

    (Below is snippet for just the main function; UCMODE_2 is used; I don't see the UCA0STE going active and hence no SPI communication):

    void main(void)
    {
    //Stop watchdog timer
    WDT_A_hold(WDT_A_BASE);

    //P3.5 UCA0SOMI as input
    GPIO_setAsPeripheralModuleFunctionInputPin(
    GPIO_PORT_P3,
    GPIO_PIN5
    );
    //P3.0 UCA0CLK, P3.3 UCA0STE and P3.4 UCA0SIMO as inputs
    GPIO_setAsPeripheralModuleFunctionOutputPin(
    GPIO_PORT_P3,
    GPIO_PIN0 + GPIO_PIN3 + GPIO_PIN4
    );

    //Initialize Master
    USCI_A_SPI_initMasterParam param = {0};
    param.selectClockSource = USCI_A_SPI_CLOCKSOURCE_SMCLK;
    param.clockSourceFrequency = UCS_getSMCLK();
    param.desiredSpiClock = SPICLK;
    param.msbFirst = USCI_A_SPI_MSB_FIRST;
    param.clockPhase = USCI_A_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT;
    param.clockPolarity = USCI_A_SPI_CLOCKPOLARITY_INACTIVITY_HIGH;
    returnValue = USCI_A_SPI_initMaster(USCI_A0_BASE, &param);

    if(STATUS_FAIL == returnValue)
    {
    return;
    }

    //Enable SPI module
    USCI_A_SPI_enable(USCI_A0_BASE);

    //Enable Receive interrupt
    USCI_A_SPI_clearInterrupt(USCI_A0_BASE,
    USCI_A_SPI_RECEIVE_INTERRUPT);
    USCI_A_SPI_enableInterrupt(USCI_A0_BASE,
    USCI_A_SPI_RECEIVE_INTERRUPT);


    //Wait for slave to initialize
    __delay_cycles(100);

    //Initialize data values
    transmitData = 0x00;

    //CS is in UCMODE_2, so Active High for Master
    GPIO_setOutputHighOnPin(
    GPIO_PORT_P3,
    GPIO_PIN3
    );

    //USCI_A0 TX buffer ready?
    while(!USCI_A_SPI_getInterruptStatus(USCI_A0_BASE,
    USCI_A_SPI_TRANSMIT_INTERRUPT))
    {
    ;
    }

    //Transmit Data to slave
    USCI_A_SPI_transmitData(USCI_A0_BASE, transmitData);

    //CPU off, enable interrupts
    __bis_SR_register(LPM0_bits + GIE);
    }

  • I got my answer in the thread below in Jens-Michael Gross's reply.
    e2e.ti.com/.../254646

**Attention** This is a public forum