Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

MSP432P401R: Master SPI 4 wire interface setup using DriverLib

$
0
0

Part Number:MSP432P401R

Hi,

I'm attempting to communicate with an external Flash using 4 wire SPI protocol. I can't see a way of doing this completely in DriverLib. I had to revert to setting a bit in the peripheral register manually, see code snippet below.

As for why this bit needs to be set at all, I guess has to do with errata USCI50 ?

This is using simplelink_msp432p4_sdk_2_30_00_14.

So I guess my question is, how do I set UCSTEM = 1 per errata USCI50 using DriverLib?


Edward

//Ext Flash IO
#include <stdint.h>
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

#define EXTFLASH_SPI_BASE EUSCI_A1_BASE

const uint8_t port7_mapping[] =
{
    //Port P7:
    PMAP_NONE,      PMAP_NONE,      PMAP_NONE,      PMAP_NONE,
    PMAP_UCA1STE,   PMAP_UCA1SIMO,  PMAP_UCA1SOMI,  PMAP_UCA1CLK    // External Flash port map
};

const eUSCI_SPI_MasterConfig spiMasterConfig =
{
    EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
    12000000,
    12000000,
    EUSCI_SPI_MSB_FIRST,
    EUSCI_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT,
    EUSCI_SPI_CLOCKPOLARITY_INACTIVITY_LOW,
    EUSCI_SPI_4PIN_UCxSTE_ACTIVE_LOW
};

uint32_t extFlashInit()
{
    // set up SPI peripheral
    SPI_initMaster(EXTFLASH_SPI_BASE, &spiMasterConfig);
    EUSCI_A_CMSIS(EXTFLASH_SPI_BASE)->CTLW0 |= EUSCI_A_CTLW0_STEM; // HACK to get 4 wire working
    SPI_enableModule(EXTFLASH_SPI_BASE);

    // set up port I/O
    PMAP_configurePorts((const uint8_t *) port7_mapping, PMAP_P7MAP, 1,
            PMAP_ENABLE_RECONFIGURATION);

    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P7,
                                                GPIO_PIN4 | GPIO_PIN5 | GPIO_PIN7,
                                                GPIO_PRIMARY_MODULE_FUNCTION);
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P7,
                                               GPIO_PIN6,
                                               GPIO_PRIMARY_MODULE_FUNCTION);

    return 0;
}




Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>