Other Parts Discussed in Thread: HALCOGEN
Hi,
I'm testing SPI in TMS570LS12x launch pad according to example_spi_Master_Slave.c in HalCogen. Because of there isn't SPI2 in my launch pad, I use SPI3 as slave. I think SPI1 works in poll mode and SPI3 in interrupt mode. It seems communication was failed by observing the receiving buffers of SPI1 and SPI3 via break point shown as below. Please help me to find out something wrong I made or missed.
The connections of pins are shown as below.
My configurations of PINMUX, driver enable, VIM, SPI1 and SPI3 are shown as below.
The test code is almost identical to example_spi_Master_Slave.c, except for SPI3 but SPI2, shown as below.
/* USER CODE BEGIN (0) */
/* USER CODE END */
/* Include Files */
#include "sys_common.h"
/* USER CODE BEGIN (1) */
#include "spi.h"
/* USER CODE END */
/* USER CODE BEGIN (2) */
uint16 TX_Data_Master[16] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 };
uint16 TX_Data_Slave[16] = { 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20 };
uint16 RX_Data_Master[16] = { 0 };
uint16 RX_Data_Slave[16] = { 0 };
/* USER CODE END */
int main(void)
{
/* USER CODE BEGIN (3) */
spiDAT1_t dataconfig1_t;
dataconfig1_t.CS_HOLD = FALSE;
dataconfig1_t.WDEL = TRUE;
dataconfig1_t.DFSEL = SPI_FMT_0;
dataconfig1_t.CSNR = 0xFE;
/* Enable CPU Interrupt through CPSR */
_enable_IRQ();
/* Initialize SPI Module Based on GUI configuration
* SPI1 - Master ( SIMO, SOMI, CLK, CS0 )
* SPI3 - Slave ( SIMO, SOMI, CLK, CS0 )
* */
spiInit();
/* Initiate SPI3 Transmit and Receive through Interrupt Mode */
spiSendAndGetData(spiREG3, &dataconfig1_t, 16, TX_Data_Slave, RX_Data_Slave);
/* Initiate SPI1 Transmit and Receive through Polling Mode*/
spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, TX_Data_Master, RX_Data_Master);
while(1);
/* USER CODE END */
return 0;
}
/* USER CODE BEGIN (4) */
/* USER CODE END */
There is also one point confused me that only RXINT of SPI3 could be enabled in HalCoGen shown as below.
Best Regards
Datïan





