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.
工具/软件:TI-RTOS
嗨、伙计
我将 Ginkgo 工具用作从机模块、我将 EXP_MSP430F5529LP 用作主模块、当从模块将数据发送到主器件(例如"ABCD12")时、但在主器件接收到完成后、我再次调用 SPI_TRANSFER ()函数来接收数据。 但是、当从机不发送数据时、主机为什么仍然接收数据? 和上次收到的相同数据(例如“22222222”) ,我不知道为什么。
代码如下所示
void spiB1_master_taskFxn (UArg0、UArgarg1) { /*创建 I2C 以供使用*/ 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 ("初始化 SPI B1\n"时出错); } 否则{ System_printf ("SPI B1已初始化!\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 ("错误 GateMutex2_create\n"); } 否则{ System_printf ("GateMutex2_create OK!\n"); } SPI_Transaction spiTransaction; IArg 键; while (1){ // KEY = GateMutex_enter (gatemutex2_handle); //Cs 低电平 Board_SPIB1_MASTER_CS_LOW;
char rxbuf[7]; spiTransaction.txBuf =空; spiTransaction.rxBuf = rxbuf; spiTransaction.count = 6; if (spi_transfer (spiB1_master、&spiTransaction)= NULL){ System_printf ("SPI 总线故障\n"); system_flush(); } //Cs 高 Board_SPIB1_MASTER_CS_HIGH; rxbuf[6]= 0; printf ("任务 spib1_master 接收数据:%s\r\n、rxbuf); // GateMutex_leave (gatemutex2_handle、key); Task_sleep (1000); GPIO_TOGGLE (Board_LED_P4_7);} } int main (void) { /*呼叫板初始化函数*/ Board_initGeneral(); Board_initGPIO(); Board_initUART(); Board_initI2C(); Board_initSPI(); //spiB1主站 taskParams.arg0 = 1000; taskParams.STACKSIZE = TASKSTACKSIZE; taskParams.stack = spiB1_master_taskStack; Task_construction (&spiB1_master_taskStruct,(Task_Functr) spiB1_master_taskFxn、&taskParams、NULL); /*启动 BIOS */ BIOS_start(); 返回(0); }
此致
XC.mo