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.
Tool/software: TI-RTOS
hi
my version:
ccsv7.4
tidriver_msp43x_2_20_00_08
bios_6_46_00_23
I'm still using the EXP_MSP430F5529LP development board to verify SPI communication, Recently , I'm stuck in the SPI_transfer() function. config spi slave mode under TI-RTOS.
target: SPI master sends a byte, spi slave judge the byte and to continue receiving or sending data.
here is my config
/* Create I2C for usage */ SPI_Params_init(&spiB1_slave_Params); spiB1_slave_Params.transferMode = SPI_MODE_BLOCKING; spiB1_slave_Params.mode = SPI_SLAVE; spiB1_slave_Params.dataSize = 8; spiB1_slave = SPI_open(Board_SPIB1_SLAVE, &spiB1_slave_Params); if (spiB1_slave == NULL) { System_abort("Error Initializing SPI B1\n"); }else { System_printf("SPI B1 Initialized!\n"); } System_flush();
issue I use the following two pieces of code for data reception validation
//code 1 //disposable recept 3 bytes SPI_Transaction spiTransaction; spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf; spiTransaction.count = 3; if (SPI_transfer(spiB1_slave, &spiTransaction) == NULL) { System_printf("SPIB1_SendData SPI Bus fault\n"); System_flush(); } System_printf("%s\r\n",rxBuf); System_flush(); //code 2 //first recept 1 bytes SPI_Transaction spiTransaction; spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf; spiTransaction.count = 1; if (SPI_transfer(spiB1_slave, &spiTransaction) == NULL) { System_printf("SPIB1_SendData SPI Bus fault\n"); System_flush(); } //continue recept 2 bytes spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf+1; spiTransaction.count = 2; if (SPI_transfer(spiB1_slave, &spiTransaction) == NULL) { System_printf("SPIB1_SendData SPI Bus fault\n"); System_flush(); } System_printf("%s\r\n",rxBuf); System_flush();
result
When I using the spi master send three bytes at a time, code 1 receive data is ok, buf code 1 will block in the second SPI_transfer();
When I using the spi master send three bytes each byte is one second apart, code 1 2 receive data both is ok.
Why is this problem?
best wishes
xc.mo
issue 2. When I using the spi master send two bytes at a time, and slave module use code 3 , why receive data is ok?
When I using the spi master send three bytes at a time, and slave module use code 4 , why block in the second SPI_transfer()?
//code 3 //recept two byte spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf; spiTransaction.count = 1; if (SPI_transfer(spi_handle, &spiTransaction) == NULL) { System_printf("SPIB1_ReceData SPI Bus fault\n"); System_flush(); } spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf+1; spiTransaction.count = 1; if (SPI_transfer(spi_handle, &spiTransaction) == NULL) { System_printf("SPIB1_SendData SPI Bus fault\n"); System_flush(); } //code 4 //recept three byte spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf; spiTransaction.count = 1; if (SPI_transfer(spi_handle, &spiTransaction) == NULL) { System_printf("SPIB1_ReceData SPI Bus fault\n"); System_flush(); } spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf+1; spiTransaction.count = 1; if (SPI_transfer(spi_handle, &spiTransaction) == NULL) { System_printf("SPIB1_SendData SPI Bus fault\n"); System_flush(); } spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf+2; spiTransaction.count = 1; //note: will block here if (SPI_transfer(spi_handle, &spiTransaction) == NULL) { System_printf("SPIB1_SendData SPI Bus fault\n"); System_flush(); }
thank you
issue 3: When I using the spi master send three bytes at a time, and slave module use code 5 , why receive data is ok?
//code 5 //first recept 2 byte spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf; spiTransaction.count = 2; // if (SPI_transfer(spi_handle, &spiTransaction) == NULL) { System_printf("SPIB1_ReceData SPI Bus fault\n"); System_flush(); } spiTransaction.txBuf = NULL; spiTransaction.rxBuf = rxBuf+2; spiTransaction.count = 1; if (SPI_transfer(spi_handle, &spiTransaction) == NULL) { System_printf("SPIB1_SendData SPI Bus fault\n"); System_flush(); }
It doesn't seem like there's enough detail in your post to understand your question. Can you please include a test case that illustrates the problem?
Thanks,
-Karl-
**Attention** This is a public forum