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/MSP432E401Y: SPI is holding the system

Part Number: MSP432E401Y

Tool/software: Code Composer Studio

Hello,

I want to send a message with SPI. However, the task is not completed because the SPI channel remains open.I can run the tasks with the USR_SW1, but whenever SPI is turned on, the task is not completed.I can see the message with an oscilloscope.(CONFIG_SPI_0 = PA2/SCLK & PA4 MOSI) I think the SPI_close doesn't work either. I can't find my fault.

I used spimaster_MSP_EXP432E401Y_tirtos for my project. 

spi_tasks.zip

//***** Header Files **********************************************************
// XDC module Header Files
#include <xdc/std.h>                                                            // XDC "base types" - must be included FIRST
#include <xdc/runtime/Types.h>                                                  // XDC constants/types used in xdc.runtime pkg
#include <xdc/cfg/global.h>                                                     // For all BIOS instances created statically in RTOS .cfg file
#include <xdc/runtime/Log.h>                                                    // For any Log_info() call

// TI-RTOS Kernel Header Files
#include <ti/sysbios/BIOS.h>                                                    // BIOS module API
#include <ti/sysbios/knl/Task.h>                                                // Task APIs
#include <ti/sysbios/knl/Semaphore.h>                                           // Semaphore APIs
#include <ti/drivers/SPI.h>

// Standard C Header Files
#include <stddef.h>
#include <stdint.h>
#include <string.h>                                                          // Standard variable types and macros
#include <unistd.h>

// Peripheral Driver Header Files
#include "ti_drivers_config.h"                                                  // Syscfg Board/Drivers Header file
#include <ti/drivers/GPIO.h>                                                    // TI GPIO Driver header file

//***** Global Variables ******************************************************
extern Semaphore_Handle sem1;
extern SPI_Handle masterSpi;
extern SPI_Params spiParams;

#define THREADSTACKSIZE (1024)
#define SPI_MSG_LENGTH  (1)
#define MASTER_MSG      ("F")
#define MAX_LOOP        (10)
unsigned char masterRxBuffer[SPI_MSG_LENGTH];
unsigned char masterTxBuffer[SPI_MSG_LENGTH];

SPI_Transaction transaction;
bool            transferOK;

//*****************************************************************************
// Task 1 Function
//*****************************************************************************
void task1Fxn(UArg a0, UArg a1)
{
    //while (1)
    {
        Semaphore_pend(sem1, BIOS_WAIT_FOREVER);                                // Wait for semaphore from HWI callback function
        GPIO_toggle(CONFIG_GPIO_LED_0);                                         // Toggle LED1 (red LED)
        Semaphore_post (sem1);
    }
}

void task2Fxn(UArg a0, UArg a1)
{
    //while (1)
       {
        Semaphore_pend(sem1, BIOS_WAIT_FOREVER);                                // Wait for semaphore from HWI callback function
        GPIO_toggle(CONFIG_GPIO_LED_1);

                              masterSpi = SPI_open(CONFIG_SPI_0, &spiParams);
                              strncpy((char *) masterTxBuffer, MASTER_MSG, SPI_MSG_LENGTH);
                              memset((void *) masterRxBuffer, 0, SPI_MSG_LENGTH);
                              transaction.count = SPI_MSG_LENGTH;
                              transaction.txBuf = (void *) masterTxBuffer;
                              transaction.rxBuf = (void *) masterRxBuffer;
                              transferOK = SPI_transfer(masterSpi, &transaction);
                              SPI_close(masterSpi);
       }
}

Regards,
  • Hello Riza,

    Let me dig into this and I will get back to you shortly.

  • Hello
    Thank you for your interest. I defined one input except two buttons.

    GPIO_setCallback(CONFIG_GPIO_0,gpioButtonFxn2);
    GPIO_enableInt(CONFIG_GPIO_0); 

    void gpioButtonFxn2(uint_least8_t index)
    {
    Semaphore_post (sem1);
    GPIO_toggle(CONFIG_GPIO_LED_2); // Toggle LED option

    }

    void task1Fxn(UArg a0, UArg a1)
    {
    while (1)
    {
    Semaphore_pend(sem1, BIOS_WAIT_FOREVER); 

    masterSpi0 = SPI_open(CONFIG_SPI_0, &spiParams0);
    strncpy((char *) masterTxBuffer0,"A", SPI_MSG_LENGTH0);
    memset((void *) masterRxBuffer0, 0, SPI_MSG_LENGTH0);
    transaction0.count = SPI_MSG_LENGTH0;
    transaction0.txBuf = (void *) masterTxBuffer0;
    transaction0.rxBuf = (void *) masterRxBuffer0;
    transferOK0 = SPI_transfer(masterSpi0, &transaction0);
    SPI_close(masterSpi0);

    Semaphore_post (sem1);
    }
    }

    After the data ready signal (input CONFIG_GPIO_0 /PQ0) I will get from outside, I want to send and read messages over SPI_0. Interrupt is running, but the function is not complete. I couldn't use two different SPI channels by running two tasks after a data ready signal.

    spi_tasks2.zip

    I re-share the final version of the project.

    Thank you.

    Best regards.

  • Hi Riza,

    I was trying to setup a project to duplicate this issue, but it may be easier if you can zip up your project and post here.

    When you post the zip file, use the "paper-clip" icon to attach the file. - thanks.

  • Hello,

    I shared my project with you in my previous post but I add it again...

    2425.spi_tasks2.zip

    Thank you again for your interest.

    Best regards.

**Attention** This is a public forum