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.

RTOS/MSP430FR5994: MSP430fr5994 EUSCI_B3 SPI TI RTOS

Part Number: MSP430FR5994

Tool/software: TI-RTOS

Hi All,

How to configure EUSCI B3 for spi in ti rtos. I am very difficult dma channel trigger and index from pdf file of data sheet. anyone knows how to configure it for spi in ti rtos? 

SPIEUSCIBDMA_Object spiEUSCIBDMAObjects[MSP_EXP430FR5994_SPICOUNT];
uint8_t spiEUSCIBDMAscratchBuf[MSP_EXP430FR5994_SPICOUNT];

const SPIEUSCIBDMA_HWAttrs spiEUSCIBDMAHWAttrs[MSP_EXP430FR5994_SPICOUNT] = {
{
.baseAddr = EUSCI_B3_BASE,
.clockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
.bitOrder = EUSCI_B_SPI_MSB_FIRST,
.scratchBufPtr = &spiEUSCIBDMAscratchBuf[0],
.defaultTxBufValue = 0,

/* DMA */
.dmaBaseAddr = DMA_BASE,
/* Rx Channel */
.rxDMAChannelIndex = DMA_CHANNEL_5,
.rxDMASourceTrigger = DMA_TRIGGERSOURCE_18,//DMA_TRIGGERSOURCE_17
/* Tx Channel */
.txDMAChannelIndex = DMA_CHANNEL_4,
.txDMASourceTrigger = DMA_TRIGGERSOURCE_19 //DMA_TRIGGERSOURCE_16
}
};

const SPI_Config SPI_config[] = {
{
.fxnTablePtr = &SPIEUSCIBDMA_fxnTable,
.object = &spiEUSCIBDMAObjects[0],
.hwAttrs = &spiEUSCIBDMAHWAttrs[0]
},
{NULL, NULL, NULL},
};

/*
* ======== MSP_EXP430FR5994_initSPI ========
*/
void MSP_EXP430FR5994_initSPI(void)
{
/* EUSCIA3 */

/* SIMO/MOSI */
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P6, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);

/* SOMI/MISO */
GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION);

/* CLK */
GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P6, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION);

SPI_init();
}

Best Regards

  • Hello,

    Here is a link to the TI RTOS guide. In there you should find how to configure your peripheral.

  • Hello Ye,

    code you have is an unreadable: no structure, no indents.
    Please, use "Insert Code, Attach Files and more..." when you post a piece of code.
  • MSP_EXP430FR5994.c
    /*
     * Copyright (c) 2016, 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.
     */
    
    /*
     *  ======== MSP_EXP430FR5994.c ========
     *  This file is responsible for setting up the board specific items for the
     *  MSP_EXP430FR5994 board.
     */
    
    #include <xdc/std.h>
    #include <xdc/runtime/System.h>
    #include <xdc/runtime/Timestamp.h>
    
    #include <msp430.h>
    #include <inc/hw_memmap.h>
    #include "driverlib.h"
    #include <dma.h>
    #include <eusci_a_uart.h>
    #include <eusci_a_spi.h>
    #include <eusci_b_i2c.h>
    #include <eusci_b_spi.h>
    #include <adc12_b.h>
    #include <gpio.h>
    #include <pmm.h>
    #include <wdt_a.h>
    
    #include "MSP_EXP430FR5994.h"
    
    #include <ti/drivers/SPI.h>
    
    
    const SPI_Config SPI_config[];
    
    /*
     *  =============================== General ===============================
     */
    /*
     *  ======== MSP_EXP430FR5994_initGeneral ========
     */
    void MSP_EXP430FR5994_initGeneral(void) {
        /*
         * Disable the GPIO power-on default high-impedance mode to activate
         * previously configured port settings
         */
        PM5CTL0 &= ~LOCKLPM5;
        GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P2,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P3,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P4,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P5,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P6,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P7,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P8,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P9,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_P10,GPIO_PIN_ALL8);
        GPIO_setAsOutputPin(GPIO_PORT_PJ,GPIO_PIN_ALL8);
    
        GPIO_setOutputLowOnPin(GPIO_PORT_P1,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P2,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P3,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P4,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P5,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P6,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P7,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P8,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P9,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_P10,GPIO_PIN_ALL8);
        GPIO_setOutputLowOnPin(GPIO_PORT_PJ,GPIO_PIN_ALL8);
    
        Comp_E_disable(COMP_E_BASE);
        Ref_A_disableTempSensor(REF_A_BASE);
        Ref_A_disableReferenceVoltage(REF_A_BASE);
        Ref_A_disableReferenceVoltageOutput(REF_A_BASE);
    }
    
    /*
     *  =============================== GPIO ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(GPIOMSP430_config, ".const:GPIOMSP430_config")
    #endif
    
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/gpio/GPIOMSP430.h>
    
    /*
     * Array of Pin configurations
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in MSP_EXP430FR5994.h
     * NOTE: Pins not used for interrupts should be placed at the end of the
     *       array.  Callback entries can be omitted from callbacks array to
     *       reduce memory usage.
     */
    GPIO_PinConfig gpioPinConfigs[] =
    {
    
    };
    
    /*
     * Array of callback function pointers
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in MSP_EXP430FR5994.h
     * NOTE: Pins not used for interrupts can be omitted from callbacks array to
     *       reduce memory usage (if placed at end of gpioPinConfigs array).
     */
    GPIO_CallbackFxn gpioCallbackFunctions[] = {
        NULL,  /* MSP_EXP430FR5994_S1 */
        NULL,   /* MSP_EXP430FR5994_S2 */
        NULL
    };
    
    /* The device-specific GPIO_config structure */
    const GPIOMSP430_Config GPIOMSP430_config = {
        .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
        .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
        .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
        .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn)
    };
    
    /*
     *  ======== MSP_EXP430FR5994_initGPIO ========
     */
    void MSP_EXP430FR5994_initGPIO(void)
    {
        /* Initialize peripheral and pins */
        GPIO_init();
    }
    
    /*
     *  =============================== I2C ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(I2C_config, ".const:I2C_config")
    #pragma DATA_SECTION(i2cEUSCIBHWAttrs, ".const:i2cEUSCIBHWAttrs")
    #endif
    
    #include <ti/drivers/I2C.h>
    #include <ti/drivers/i2c/I2CEUSCIB.h>
    
    I2CEUSCIB_Object i2cEUSCIBObjects[MSP_EXP430FR5994_I2CCOUNT];
    
    const I2CEUSCIB_HWAttrs i2cEUSCIBHWAttrs[MSP_EXP430FR5994_I2CCOUNT] = {
        {
            .baseAddr = EUSCI_B2_BASE,
            .clockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK
        }
    };
    
    const I2C_Config I2C_config[] = {
        {
            .fxnTablePtr = &I2CEUSCIB_fxnTable,
            .object = &i2cEUSCIBObjects[0],
            .hwAttrs = &i2cEUSCIBHWAttrs[0]
        },
        {NULL, NULL, NULL}
    };
    
    /*
     *  ======== MSP_EXP430FR5994_initI2C ========
     */
    void MSP_EXP430FR5994_initI2C(void)
    {
        /*
         * NOTE: TI-RTOS examples configure EUSCIB1 as either SPI or I2C.  Thus,
         * a conflict occurs when the I2C & SPI drivers are used simultaneously in
         * an application.  Modify the pin mux settings in this file and resolve the
         * conflict before running your the application.
         */
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P7, GPIO_PIN0 | GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION);
    
        I2C_init();
    }
    
    /*
     *  =============================== SDSPI ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(SDSPI_config, ".const:SDSPI_config")
    #pragma DATA_SECTION(sdspiEUSCIBHWAttrsV1, ".const:sdspiEUSCIBHWAttrsV1")
    #endif
    
    #include <ti/drivers/SDSPI.h>
    #include <ti/drivers/sdspi/SDSPIEUSCIB.h>
    
    SDSPIEUSCIB_Object sdspiEUSCIBObjects[MSP_EXP430FR5994_SDSPICOUNT];
    
    const SDSPIEUSCIB_HWAttrsV1 sdspiEUSCIBHWAttrsV1[MSP_EXP430FR5994_SDSPICOUNT] = {
        {
            .baseAddr = EUSCI_B0_BASE,
            .clockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
    
            .portSCK = GPIO_PORT_P2,
            .pinSCK = GPIO_PIN2,
            .pinSCKModeFunction = GPIO_SECONDARY_MODULE_FUNCTION,
    
            .portMISO = GPIO_PORT_P1,
            .pinMISO = GPIO_PIN7,
            .pinMISOModeFunction = GPIO_SECONDARY_MODULE_FUNCTION,
    
            .portMOSI = GPIO_PORT_P1,
            .pinMOSI = GPIO_PIN6,
            .pinMOSIModeFunction = GPIO_SECONDARY_MODULE_FUNCTION,
    
            .portCS = GPIO_PORT_P4,
            .pinCS = GPIO_PIN3
        }
    };
    
    const SDSPI_Config SDSPI_config[] = {
        {
            .fxnTablePtr = &SDSPIEUSCIB_fxnTable,
            .object = &sdspiEUSCIBObjects[0],
            .hwAttrs = &sdspiEUSCIBHWAttrsV1[0]
        },
        {NULL, NULL, NULL}
    };
    
    /*
     *  ======== MSP_EXP430FR5994_initSDSPI ========
     */
    void MSP_EXP430FR5994_initSDSPI(void)
    {
        SDSPI_init();
    }
    
    /*
     *  =============================== SPI ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(SPI_config, ".const:SPI_config")
    #pragma DATA_SECTION(spiEUSCIBDMAHWAttrs, ".const:spiEUSCIADMAHWAttrs")
    #endif
    
    #include <ti/drivers/SPI.h>
    #include <ti/drivers/spi/SPIEUSCIBDMA.h>
    
    SPIEUSCIBDMA_Object spiEUSCIBDMAObjects[MSP_EXP430FR5994_SPICOUNT];
    uint8_t spiEUSCIBDMAscratchBuf[MSP_EXP430FR5994_SPICOUNT];
    
    const SPIEUSCIBDMA_HWAttrs spiEUSCIBDMAHWAttrs[MSP_EXP430FR5994_SPICOUNT] = {
        {
             .baseAddr = EUSCI_B3_BASE,
             .clockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
             .bitOrder = EUSCI_B_SPI_MSB_FIRST,
             .scratchBufPtr = &spiEUSCIBDMAscratchBuf[0],
             .defaultTxBufValue = 0,
    
             /* DMA */
             .dmaBaseAddr = DMA_BASE,
             /* Rx Channel */
             .rxDMAChannelIndex = DMA_CHANNEL_5,
             .rxDMASourceTrigger = DMA_TRIGGERSOURCE_18,//DMA_TRIGGERSOURCE_17
             /* Tx Channel */
             .txDMAChannelIndex = DMA_CHANNEL_4,
             .txDMASourceTrigger = DMA_TRIGGERSOURCE_19 //DMA_TRIGGERSOURCE_16
        }
    };
    
    const SPI_Config SPI_config[] = {
        {
            .fxnTablePtr = &SPIEUSCIBDMA_fxnTable,
            .object = &spiEUSCIBDMAObjects[0],
            .hwAttrs = &spiEUSCIBDMAHWAttrs[0]
        },
        {NULL, NULL, NULL},
    };
    
    /*
     *  ======== MSP_EXP430FR5994_initSPI ========
     */
    void MSP_EXP430FR5994_initSPI(void)
    {
        /* EUSCIA3 */
    
        /* SIMO/MOSI */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P6, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);
    
        /* SOMI/MISO */
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION);
    
        /* CLK */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P6, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION);
    
        SPI_init();
    }
    
    /*
     *  =============================== DMA ===============================
     */
    /*
     *  ======== MSP_EXP430FR5994_isrDMA ========
     *  This is a application defined DMA ISR. This ISR must map and call the
     *  appropriate Driver_event(handle) API to indicate completed DMA transfers.
     */
    Void MSP_EXP430FR5994_isrDMA(UArg arg)
    {
        /* Call the SPI DMA function, passing the SPI handle used for WiFi */
        SPI_serviceISR((SPI_Handle) &(SPI_config[0]));
    }
    
    /*
     *  =============================== UART ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(UART_config, ".const:UART_config")
    #pragma DATA_SECTION(uartEUSCIAHWAttrs, ".const:uartEUSCIAHWAttrs")
    #endif
    
    #include <ti/drivers/UART.h>
    #include <ti/drivers/uart/UARTEUSCIA.h>
    
    UARTEUSCIA_Object uartEUSCIAObjects[MSP_EXP430FR5994_UARTCOUNT];
    
    /*
     * The baudrate dividers were determined by using the MSP430 baudrate
     * calculator
     * http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSP430BaudRateConverter/index.html
     */
    const UARTEUSCIA_BaudrateConfig uartEUSCIABaudrates[] = {
        /* {baudrate, input clock, prescalar, UCBRFx, UCBRSx, oversampling} */
    #ifdef RS485
        {
            .outputBaudrate = 115200,
            .inputClockFreq = 8000000,
            .prescalar = 4,
            .hwRegUCBRFx = 5,
            .hwRegUCBRSx = 85,
            .oversampling = 1
        },
    #endif
        {
            .outputBaudrate = 9600,
            .inputClockFreq = 8000000,
            .prescalar = 52,
            .hwRegUCBRFx = 1,
            .hwRegUCBRSx = 0,
            .oversampling = 1
        },
        {
            .outputBaudrate = 9600,
            .inputClockFreq = 8000000,
            .prescalar = 52,
            .hwRegUCBRFx = 1,
            .hwRegUCBRSx = 0,
            .oversampling = 1
        },
        {9600,   32768,  3, 0, 3, 0},
    };
    
    const UARTEUSCIA_HWAttrs uartEUSCIAHWAttrs[MSP_EXP430FR5994_UARTCOUNT] = {
        {
            .baseAddr = EUSCI_A0_BASE,
            .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
            .bitOrder = EUSCI_A_UART_LSB_FIRST,
            .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
            .baudrateLUT = uartEUSCIABaudrates
        },
        {
            .baseAddr = EUSCI_A1_BASE,
            .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
            .bitOrder = EUSCI_A_UART_LSB_FIRST,
            .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
            .baudrateLUT = uartEUSCIABaudrates
        },
        {
            .baseAddr = EUSCI_A2_BASE,
            .clockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK,
            .bitOrder = EUSCI_A_UART_LSB_FIRST,
            .numBaudrateEntries = sizeof(uartEUSCIABaudrates)/sizeof(UARTEUSCIA_BaudrateConfig),
            .baudrateLUT = uartEUSCIABaudrates
        },
    };
    
    const UART_Config UART_config[] = {
        {
            .fxnTablePtr = &UARTEUSCIA_fxnTable,
            .object = &uartEUSCIAObjects[0],
            .hwAttrs = &uartEUSCIAHWAttrs[0]
        },
        {
            .fxnTablePtr = &UARTEUSCIA_fxnTable,
            .object = &uartEUSCIAObjects[1],
            .hwAttrs = &uartEUSCIAHWAttrs[1]
        },
        {
            .fxnTablePtr = &UARTEUSCIA_fxnTable,
            .object = &uartEUSCIAObjects[2],
            .hwAttrs = &uartEUSCIAHWAttrs[2]
        },
        {NULL, NULL, NULL}
    };
    
    /*
     *  ======== MSP_EXP430FR5994_initUART ========
     */
    void MSP_EXP430FR5994_initUART(void)
    {
        /* P2.0,1 = EUSCI_A0 TXD/RXD */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P5, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5, GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION);
    
        /* P2.0,1 = EUSCI_A3 TXD/RXD */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN5, GPIO_SECONDARY_MODULE_FUNCTION);
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2, GPIO_PIN6, GPIO_SECONDARY_MODULE_FUNCTION);
    
        /* P2.0,1 = EUSCI_A3 TXD/RXD */
        GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P2, GPIO_PIN0, GPIO_SECONDARY_MODULE_FUNCTION);
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P2, GPIO_PIN1, GPIO_SECONDARY_MODULE_FUNCTION);
        /* Initialize the UART driver */
        UART_init();
    }
    
    /*
     *  =============================== Watchdog ===============================
     */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(Watchdog_config, ".const:Watchdog_config")
    #pragma DATA_SECTION(watchdogMSP430HWAttrs, ".const:watchdogMSP430HWAttrs")
    #endif
    
    #include <ti/drivers/Watchdog.h>
    #include <ti/drivers/watchdog/WatchdogMSP430.h>
    
    WatchdogMSP430_Object watchdogMSP430Objects[MSP_EXP430FR5994_WATCHDOGCOUNT];
    
    const WatchdogMSP430_HWAttrs watchdogMSP430HWAttrs[MSP_EXP430FR5994_WATCHDOGCOUNT] = {
        {
            .baseAddr = WDT_A_BASE,
            .sfrAddr = SFR_BASE,
            .clockSource = WDT_A_CLOCKSOURCE_SMCLK,
            .clockDivider = WDT_A_CLOCKDIVIDER_8192K
        },
    };
    
    const Watchdog_Config Watchdog_config[] = {
        {
            .fxnTablePtr = &WatchdogMSP430_fxnTable,
            .object = &watchdogMSP430Objects[0],
            .hwAttrs = &watchdogMSP430HWAttrs[0]
        },
        {NULL, NULL, NULL}
    };
    
    /*
     *  ======== MSP_EXP430FR5994_initWatchdog ========
     */
    void MSP_EXP430FR5994_initWatchdog(void)
    {
        /* Initialize the Watchdog driver */
        Watchdog_init();
    }
    
    void MSP_EXP430FR5994_initADC(void)
    {
        /* Initialize the ADC driver */
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P3, GPIO_PIN0 | GPIO_PIN1 | GPIO_PIN2 | GPIO_PIN3, GPIO_TERNARY_MODULE_FUNCTION);//GPIO_TERNARY_MODULE_FUNCTION
        GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, GPIO_PIN0, GPIO_TERNARY_MODULE_FUNCTION);//GPIO_TERNARY_MODULE_FUNCTION
        ADC12_B_initParam initParam = {0};
        initParam.sampleHoldSignalSourceSelect = ADC12_B_SAMPLEHOLDSOURCE_SC;//GPIO_SECONDARY_MODULE_FUNCTION
        initParam.clockSourceSelect = ADC12_B_CLOCKSOURCE_ADC12OSC;
        initParam.clockSourceDivider = ADC12_B_CLOCKDIVIDER_1;
        initParam.clockSourcePredivider = ADC12_B_CLOCKPREDIVIDER__1;
        initParam.internalChannelMap = ADC12_B_NOINTCH;
        ADC12_B_init(ADC12_B_BASE, &initParam);
    
        ADC12_B_setResolution(ADC12_B_BASE, ADC12_B_RESOLUTION_12BIT);
        ADC12_B_setDataReadBackFormat(ADC12_B_BASE,ADC12_B_UNSIGNED_BINARY);
        ADC12_B_setAdcPowerMode(ADC12_B_BASE,ADC12_B_LOWPOWERMODE);
        ADC12_B_setupSamplingTimer(ADC12_B_BASE, ADC12_B_CYCLEHOLD_16_CYCLES, ADC12_B_CYCLEHOLD_4_CYCLES, ADC12_B_MULTIPLESAMPLESDISABLE);
    }
    

  • Use i2ctmp example as analog to find how to deal with spi.
  • Following Dennis link:



    TI-RTOS Drivers tidrivers_msp43x_2_20_00_08

    Main Page
    Modules
    Data Structures
    Files
    Related Pages

    File List
    Globals

    exports
    tidrivers_msp43x_2_20_00_08
    packages
    ti
    drivers

    Data Structures | Macros | Typedefs | Functions
    SDSPI.h File Reference
    Detailed Description

    SDSPI driver interface.

    ============================================================================

    The SDSPI header file should be included in an application as follows:
    #include <ti/drivers/SDSPI.h>
    Operation

    The SDSPI driver is a driver designed to hook into FatFs. It implements a set of functions that FatFs needs to call to perform basic block data transfers.

    A SDSPI driver peripheral implementation doesn't require RTOS protection primitives due to the resource protection provided with FatFs. The only functions that can be called by the application are the standard driver framework functions (_open, _close, etc...).

    Once the driver has been opened, the application may used the FatFs APIs or the standard C runtime file I/O calls (fopen, fclose, etc...). Once the driver has been closed, ensure the application does NOT make any file I/O calls.
    Opening the driver
    SDSPI_Handle handle;
    SDSPI_Params params;
    SDSPI_Params_init(&params);
    params.bitRate = someNewBitRate;
    handle = SDSPI_open(someSDSPI_configIndexValue, &params);
    if (!handle) {
    System_printf("SDSPI did not open");
    }
    Implementation

    This module serves as the main interface for TI-RTOS applications. Its purpose is to redirect the module's APIs to specific peripheral implementations which are specified using a pointer to a SDSPI_FxnTable.

    The SDSPI driver interface module is joined (at link time) to a NULL-terminated array of SDSPI_Config data structures named SDSPI_config. SDSPI_config is implemented in the application with each entry being an instance of a SDSPI peripheral. Each entry in SDSPI_config contains a:

    (SDSPI_FxnTable *) to a set of functions that implement a SDSPI peripheral
    (void *) data object that is associated with the SDSPI_FxnTable
    (void *) hardware attributes that are associated to the SDSPI_FxnTable

    Instrumentation

    The SDSPI driver interface produces log statements if instrumentation is enabled.
    Diagnostics Mask Log details
    Diags_USER1 basic operations performed
    Diags_USER2 detailed operations performed
    #include <stdint.h>

    Go to the source code of this file.
    Data Structures
    struct SDSPI_Params
    SDSPI Parameters. More...

    struct SDSPI_FxnTable
    The definition of a SDSPI function table that contains the required set of functions to control a specific SDSPI driver implementation. More...

    struct SDSPI_Config
    SDSPI Global configuration. More...

    Macros
    #define SDSPI_CMD_RESERVED 32

    #define SDSPI_STATUS_RESERVED -32

    #define SDSPI_STATUS_SUCCESS 0
    Successful status code returned by SDSPI_control(). More...

    #define SDSPI_STATUS_ERROR -1
    Generic error status code returned by SDSPI_control(). More...

    #define SDSPI_STATUS_UNDEFINEDCMD -2
    An error status code returned by SDSPI_control() for undefined command codes. More...

    Typedefs
    typedef struct SDSPI_Config * SDSPI_Handle
    A handle that is returned from a SDSPI_open() call. More...

    typedef struct SDSPI_Params SDSPI_Params
    SDSPI Parameters. More...

    typedef void(* SDSPI_InitFxn) (SDSPI_Handle handle)
    A function pointer to a driver specific implementation of SDSPI_init(). More...

    typedef SDSPI_Handle(* SDSPI_OpenFxn) (SDSPI_Handle handle, unsigned char drv, SDSPI_Params *params)
    A function pointer to a driver specific implementation of SDSPI_open(). More...

    typedef void(* SDSPI_CloseFxn) (SDSPI_Handle handle)
    A function pointer to a driver specific implementation of SDSPI_close(). More...

    typedef int(* SDSPI_ControlFxn) (SDSPI_Handle handle, unsigned int cmd, void *arg)
    A function pointer to a driver specific implementation of SDSPI_control(). More...

    typedef struct SDSPI_FxnTable SDSPI_FxnTable
    The definition of a SDSPI function table that contains the required set of functions to control a specific SDSPI driver implementation. More...

    typedef struct SDSPI_Config SDSPI_Config
    SDSPI Global configuration. More...

    Functions
    void SDSPI_close (SDSPI_Handle handle)
    Function to close a SDSPI peripheral specified by the SDSPI handle. This function unmounts the file system mounted by SDSPI_open and unregisters the SDSPI driver from BIOS' FatFs module. More...

    int SDSPI_control (SDSPI_Handle handle, unsigned int cmd, void *arg)
    Function performs implementation specific features on a given SDSPI_Handle. More...

    void SDSPI_init (void)
    This function initializes the SDSPI driver module. More...

    SDSPI_Handle SDSPI_open (unsigned int index, unsigned char drv, SDSPI_Params *params)
    This function registers the SDSPI driver with BIOS' FatFs module and mounts the FatFs file system. More...

    void SDSPI_Params_init (SDSPI_Params *params)
    Function to initialize the SDSPI_Params struct to its defaults. More...

    Typedef Documentation
    typedef struct SDSPI_Config* SDSPI_Handle

    A handle that is returned from a SDSPI_open() call.
    typedef struct SDSPI_Params SDSPI_Params

    SDSPI Parameters.

    SDSPI Parameters are used to with the SDSPI_open() call. Default values for these parameters are set using SDSPI_Params_init().

    See also
    SDSPI_Params_init()

    typedef void(* SDSPI_InitFxn) (SDSPI_Handle handle)

    A function pointer to a driver specific implementation of SDSPI_init().
    typedef SDSPI_Handle(* SDSPI_OpenFxn) (SDSPI_Handle handle, unsigned char drv, SDSPI_Params *params)

    A function pointer to a driver specific implementation of SDSPI_open().
    typedef void(* SDSPI_CloseFxn) (SDSPI_Handle handle)

    A function pointer to a driver specific implementation of SDSPI_close().
    typedef int(* SDSPI_ControlFxn) (SDSPI_Handle handle, unsigned int cmd, void *arg)

    A function pointer to a driver specific implementation of SDSPI_control().
    typedef struct SDSPI_FxnTable SDSPI_FxnTable

    The definition of a SDSPI function table that contains the required set of functions to control a specific SDSPI driver implementation.
    typedef struct SDSPI_Config SDSPI_Config

    SDSPI Global configuration.

    The SDSPI_Config structure contains a set of pointers used to characterize the SDSPI driver implementation.

    This structure needs to be defined before calling SDSPI_init() and it must not be changed thereafter.

    See also
    SDSPI_init()

    Function Documentation
    void SDSPI_close ( SDSPI_Handle handle )

    Function to close a SDSPI peripheral specified by the SDSPI handle. This function unmounts the file system mounted by SDSPI_open and unregisters the SDSPI driver from BIOS' FatFs module.

    Precondition
    SDSPI_open() had to be called first.

    Parameters
    handle A SDSPI handle returned from SDSPI_open

    See also
    SDSPI_open()

    int SDSPI_control ( SDSPI_Handle handle,
    unsigned int cmd,
    void * arg
    )

    Function performs implementation specific features on a given SDSPI_Handle.

    Commands for SDSPI_control can originate from SDSPI.h or from implementation specific SDSPI*.h (SDSPICC26XX.h, SDSPITiva.h, etc.. ) files. While commands from SDSPI.h are API portable across driver implementations, not all implementations may support all these commands. Conversely, commands from driver implementation specific SDSPI*.h files add unique driver capabilities but are not API portable across all SDSPI driver implementations.

    Commands supported by SDSPI.h follow a SDSPI_CMD_<cmd> naming convention.
    Commands supported by SDSPI*.h follow a SDSPI*_CMD_<cmd> naming convention.
    Each control command defines arg differently. The types of arg are documented with each command.

    See SDSPI_control command codes for command codes.

    See SDSPI_control return status codes for status codes.

    Precondition
    SDSPI_open() has to be called first.

    Parameters
    handle A SDSPI handle returned from SDSPI_open()
    cmd SDSPI.h or SDSPI*.h commands.
    arg An optional R/W (read/write) command argument accompanied with cmd

    Returns
    Implementation specific return codes. Negative values indicate unsuccessful operations.

    See also
    SDSPI_open()

    void SDSPI_init ( void )

    This function initializes the SDSPI driver module.

    Precondition
    The SDSPI_config structure must exist and be persistent before this function can be called. This function must also be called before any other SDSPI driver APIs. This function call does not modify any peripheral registers.

    SDSPI_Handle SDSPI_open ( unsigned int index,
    unsigned char drv,
    SDSPI_Params * params
    )

    This function registers the SDSPI driver with BIOS' FatFs module and mounts the FatFs file system.

    Precondition
    SDSPI controller has been initialized using SDSPI_init()

    Parameters
    index Logical peripheral number for the SDSPI indexed into the SDSPI_config table
    drv Drive number to be associated with the SDSPI FatFs driver
    params Pointer to an parameter block, if NULL it will use default values. All the fields in this structure are RO (read-only).

    Returns
    A SDSPI_Handle on success or a NULL on an error or if it has been opened already.

    See also
    SDSPI_init()
    SDSPI_close()

    void SDSPI_Params_init ( SDSPI_Params * params )

    Function to initialize the SDSPI_Params struct to its defaults.

    Parameters
    params An pointer to SDSPI_Params structure for initialization

    Defaults values are: bitRate = 12500000 (Hz)
  • Hi

    I just want to know how to configure dma channel index and dam source trigger for spi in EUSCI B3 mode for ADC chip. But I found in datasheet that both tx(UCB3TXIFG) and rx(UCB3RXIFG) share the same dma channel 5. How to configure it correctly for dma channel and trigger for EUSCI B3 for msp430fr5994.

  • The UCB3 peripheral has two separate trigger sources; one RX and one for TX as shown here in the dma trigger table from the MSP430FR5994 datasheet.

    You assign the trigger number to the the specific DMA channel that you are using in the DMACTLn register.

    For example, you can assign DMA channel 0 to the RX (DMACTL0:DMA0TSEL = 24) and DMA channel 1 to the TX (DMACTL0:DMA1TSEL = 23)

    See section 11.3 in the MSP430FR5994 users guide.

  • Hi 

    The one you circle red is trigger 24 and 25 but you written it 24 and 23. which one is correct? 24 and 25 is for I2C and cannot use it for SPI? How do I write it in TI RTOS?

    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(SPI_config, ".const:SPI_config")
    #pragma DATA_SECTION(spiEUSCIBDMAHWAttrs, ".const:spiEUSCIBDMAHWAttrs")
    #endif

    #include <ti/drivers/SPI.h>
    #include <ti/drivers/spi/SPIEUSCIBDMA.h>

    SPIEUSCIBDMA_Object spiEUSCIBDMAObjects[MSP_EXP430FR5994_SPICOUNT];
    uint8_t spiEUSCIBDMAscratchBuf[MSP_EXP430FR5994_SPICOUNT];

    const SPIEUSCIBDMA_HWAttrs spiEUSCIBDMAHWAttrs[MSP_EXP430FR5994_SPICOUNT] = {
    {
    .baseAddr = EUSCI_B3_BASE,
    .clockSource = EUSCI_B_SPI_CLOCKSOURCE_SMCLK,
    .bitOrder = EUSCI_B_SPI_MSB_FIRST,
    .scratchBufPtr = &spiEUSCIBDMAscratchBuf[0],
    .defaultTxBufValue = 0,

    .dmaBaseAddr = DMA_BASE,
    .rxDMAChannelIndex = DMA_CHANNEL_0,
    .rxDMASourceTrigger = DMA_TRIGGERSOURCE_24,//DMA_TRIGGERSOURCE_17
    .txDMAChannelIndex = DMA_CHANNEL_1,
    .txDMASourceTrigger = DMA_TRIGGERSOURCE_23 //DMA_TRIGGERSOURCE_16
    }
    };

    const SPI_Config SPI_config[] = {
    {
    .fxnTablePtr = &SPIEUSCIBDMA_fxnTable,
    .object = &spiEUSCIBDMAObjects[0],
    .hwAttrs = &spiEUSCIBDMAHWAttrs[0]
    },
    {NULL, NULL, NULL},
    };

    /*
    * ======== MSP_EXP430FR5994_initSPI ========
    */
    void MSP_EXP430FR5994_initSPI(void)
    {
    /* EUSCIB3 */

    /* SIMO/MOSI */
    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P6, GPIO_PIN4, GPIO_PRIMARY_MODULE_FUNCTION);

    /* SOMI/MISO */
    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P6, GPIO_PIN5, GPIO_PRIMARY_MODULE_FUNCTION);

    /* CLK */
    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P6, GPIO_PIN6, GPIO_PRIMARY_MODULE_FUNCTION);

    SPI_init();
    }

    Best Regards

  • Hi

    I am using EUSCI B3 for SPI. I try your suggestion in ti rtos and still not working. Thanks for your help.

    Best Regards
  • I was wrong regarding trigger 23,24; I meant so say 24,25. The table is correct. Did you try trigger 24,25?
  • Dear Dennis,

    my understanding is that according the documentation, in case of EUSCB3, the Tx and Rx cannot have separate DMA channels.
    My understanding is EUSCB3 cannot be driven by TI-RTOS drivers.
  • Hi Dennis

    I try to trigger 24 and 25 according to your suggestion but still cannot. There is only 1 dma channel for tx and rx? I try to use EUSCI A3 and it is working. for EUSCI B3, semaphore is blocking (meaning that waiting for dma to trigger). can you try this at your side?

    Best Regards
    Thanks
  • Hi Dennis

    I try to trigger 24,25 and sill not working. can you try this at your side? I use EUSCI A3 for spi and it is working. Is there only 1 dma channel for tx and rx for EUSCI B3? TI has very few examples and sometimes very difficult to fix.


    Best regards
    Thanks
  • Following up on last response - were you able to get your DMA working with trigger 24,25?
  • Hi dennis,

    There is no dma trigger 24,25. it is still blocking at semaphore so meaning that waiting. can you try this at your side for work around as i design board already.
  • Ok, since this appears to be directly related to TI-RTOS, I'm going to switch this E2E over to that team.
  • I'm not sure but my read of the chart says that for UCB3 and SPI, you should use DMA channel 5 for both and triggers 18, and 19 for RX and TX respectively.

    Alan
  • Hello Alan,
    could you explain me how to use one DMA channel for two separate transfers going asynchronously?
  • It looks like I may have given you bad advice. I am checking with an MSP430 team expert to find out whether you can use DMA for both tx and rx on EUSCB3. In the meantime, is there a compelling reason for you to use EUSCB3 rather than EUSCB0 which seems to support unique DMA channels for TX and RX?

    Alan
  • Alan,

    I tried to help our colleague ye myat thu.
    I have joined this thread because of a partial DMA support for EUSCB3.
    It is easy job to use driverlibs for EUSCB3.

    I assume that many MCUs may have this kind of a partial DMA support.
    Might happen I would need to modify TI-RTOS driver to use DMA for Rx and interrupts for Tx on any I/O channel.

    I have basic, however positive experience customizing driverlibs.
    Do you have any hints how to modify TI-RTOS drivers?
  • If you're developing your application as a CCS project, simply copy the src/ti/drivers/spi/SPIUSCIBDMA.c and SPIUSCIBDMA.h files into your project and start making your changes. Your project's version of the APIs in the SPIUSCIBDMA.c file will be used rather than the one's in the driver library.

    Alan
  • Hi Alan,

    I cannot use EUSCB0 spi as pcb is designed already and I do not understand why TI has 1 channel for tx and rx for EUSCB3. Is there a way to solve using software as PCB is designed already? I try DMA channel 5 for both and triggers 18, and 19 for RX and TX and not working.
  • Hi Alan

    Where do I change in src/ti/drivers/spi/SPIUSCIBDMA.c ? You have sample to make changes or can you show where I should change in src/ti/drivers/spi/SPIUSCIBDMA.c ?

    Thanks for your help.
  • Hello Ye,

    you need to analyze how how this driver works to understand how to change it.
    In my modest opinion it would be easier for you to use driverlibs and an existing example showing how to cope with it.
  • I confirmed with the MSP430 experts that DMA can only by used for either TX or RX, not both, on EUSCB3. As noted, the SPI driver was not designed to support this restriction.

    As Tomasz stated, you'll have to study and rework the driver source code to get it to behave the way you want it to.

    Alan

  • Hi Alan

    Thanks for info.

    Best Regards

**Attention** This is a public forum