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.
//***** 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,