Other Parts Discussed in Thread: HALCOGEN
Hello,
I am using TMS57004 Launchpad. Current I am working on SPI communication. For that I have gone through Halcogen example. I want to use SPI1 in normal (not in Mibspi) mode(MASTER mode) using interrupt method.
For SPI1 interrupt method I have set all the parameter as you have mentioned in example for SPI2 slave.
After all setting when I execute the
spiSendAndGetData(spiREG1,&dataconfig1_t,2 TX_Data_Master,Rx_Data_Master)
where uint8 Tx_Data_Master[2]={0x44,0xAA); Rx_Data_Master[2]={0};
I receive only second byte correctly and first byte as all one. So, could you any one tell is there any wrong in my configuration.
Below is my sample code:
Int main(void)
{
spiDAT1_t dataconfig1_t;
dataconfig1_t.CS_HOLD = TRUE;
dataconfig1_t.WDEL = TRUE;
dataconfig1_t.DFSEL = SPI_FMT_1;
dataconfig1_t.CSNR = 0xFC;
/* Enable CPU Interrupt through CPSR */
_enable_IRQ();
spiInit();
while(1)
{
spiSendAndGetData(spiREG1,&dataconfig1_t,2 TX_Data_Master,Rx_Data_Master);
}
return 0;
}
void spiSendAndGetData(spiBASE_t *spi, spiDAT1_t *dataconfig_t, uint32 blocksize, uint8 * srcbuff, uint8* destbuff)
{
/* USER CODE BEGIN (17) */
/* USER CODE END */
uint32 index = spi == spiREG1 ? 0U :(spi==spiREG2 ? 1U : 2U);
g_spiPacket_t[index].tx_length = blocksize;
g_spiPacket_t[index].rx_length = blocksize;
g_spiPacket_t[index].txdata_ptr = srcbuff;
g_spiPacket_t[index].rxdata_ptr = destbuff;
g_spiPacket_t[index].g_spiDataFormat = *dataconfig_t;
g_spiPacket_t[index].tx_data_status = SPI_PENDING;
g_spiPacket_t[index].rx_data_status = SPI_PENDING;
spi->INT0 |= 0x0300U;
/* USER CODE BEGIN (18) */
/* USER CODE END */
}
static volatile struct g_spiPacket
{
spiDAT1_t g_spiDataFormat;
uint32 tx_length;
uint32 rx_length;
// uint16 * txdata_ptr;
// uint16 * rxdata_ptr;
uint8 * txdata_ptr;
uint8 * rxdata_ptr;
SpiDataStatus_t tx_data_status;
SpiDataStatus_t rx_data_status;
} g_spiPacket_t[3U];
Thanx in Advance..