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/MSP430F5529: TI-RTOS/MSP430 : SPI master module receive data is complete, After call SPI_transfer() again to receive only the last byte of data!

Part Number: MSP430F5529

Tool/software: TI-RTOS

hi guy

I use the Ginkgo tool as a slave module, I use EXP_MSP430F5529LP as a master module, and when slave module sends data to master(e.g "ABCD12"), but after master receives accomplishit, I call the SPI_transfer() function again to receive data. but when slave doesn't send data, why does master still receive data? And the same last received data(e.g "222222") , I don't know why.

code is as follows

Void spiB1_master_taskFxn(UArg arg0, UArg arg1)
{
    /* Create I2C for usage */
    SPI_Params_init(&spiB1_master_Params);
    spiB1_master_Params.transferMode          = SPI_MODE_BLOCKING;
    //spiB1_master_Params.transferCallbackFxn   = spiB1_transferCallbackFxn;
    spiB1_master_Params.mode                  = SPI_MASTER;
    spiB1_master_Params.dataSize              = 8;
    //spiB1_master_Params.frameFormat   = SPI_POL1_PHA0;

    spiB1_master = SPI_open(Board_SPIB1_MASTER, &spiB1_master_Params);
    if (spiB1_master == NULL) {
        System_abort("Error Initializing SPI B1\n");
    }
    else {
        System_printf("SPI B1 Initialized!\n");
    }
    System_flush();

    //gatemute
    GateMutex_Handle gatemutex2_handle;
    GateMutex_Params gatemutex2_params;

    GateMutex_Params_init(&gatemutex2_params);
    gatemutex2_handle = GateMutex_create(&gatemutex2_params, NULL);
    if (gatemutex2_handle == NULL) {
        System_abort("Error GateMutex2_create\n");
    }
    else {
        System_printf("GateMutex2_create OK!\n");
    }

    SPI_Transaction spiTransaction;
    IArg key;

    while(1){

        //
        key = GateMutex_enter(gatemutex2_handle);

        //cs low
        Board_SPIB1_MASTER_CS_LOW;
char rxbuf[7]; spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxbuf; spiTransaction.count = 6; if (SPI_transfer(spiB1_master, &spiTransaction) == NULL) { System_printf("SPI Bus fault\n"); System_flush(); } //cs hight Board_SPIB1_MASTER_CS_HIGH; rxbuf[6] = 0; printf("TASK spiB1_master receive DATA:%s\r\n",rxbuf); // GateMutex_leave(gatemutex2_handle, key); Task_sleep(1000); GPIO_toggle(Board_LED_P4_7);; } } int main(void) { /* Call board init functions */ Board_initGeneral(); Board_initGPIO(); Board_initUART(); Board_initI2C(); Board_initSPI(); //spiB1 master taskParams.arg0 = 1000; taskParams.stackSize = TASKSTACKSIZE; taskParams.stack = &spiB1_master_taskStack; Task_construct(&spiB1_master_taskStruct, (Task_FuncPtr)spiB1_master_taskFxn, &taskParams, NULL); /* Start BIOS */ BIOS_start(); return (0); }

my version

 

Best  regards

xc.mo

**Attention** This is a public forum