Other Parts Discussed in Thread: HALCOGEN,
Hi everybody,
I am using a Hercules TMS570LS0432 Launchpad and am using HalCoGen drivers with a lot of success. However the SPI driver has been giving me trouble.
When calling spiTransmitData() or spiTransmitAndReceiveData() functions it will sometimes (but not all the time) get stuck when waiting for the RXINTFLG bit to set, i.e. "while((spi->FLG & 0x00000100U) != 0x00000100U)". Through the debugger I can see that the SPI Flag register is set to 0x01000200 (TXINTFLG is set).
I have a 4-channel scope connected and can see that the chip select and clock lines are pulled high after clocking 8 bits, so transmission seems to have occurred okay. What am I doing wrong, and what can I do to fix this?
Following are some code snippets, I hope it's enough to help me with this.
My function call:
spiTransmitData(spiREG2, &spiFmt0, 1, txBuf);
My spiDAT1_t struct passed into the functions in question:
spiDAT1_t spiFmt0 = {
.CS_HOLD = 1,
.WDEL = 1,
.DFSEL = SPI_FMT_0,
.CSNR = 0x00
};
In HalCoGen's spiInit(void):
spiREG2->FMT0 = (uint32)((uint32)2U << 24U) /* wdelay */
| (uint32)((uint32)0U << 23U) /* parity Polarity */
| (uint32)((uint32)0U << 22U) /* parity enable */
| (uint32)((uint32)0U << 21U) /* wait on enable */
| (uint32)((uint32)0U << 20U) /* shift direction */
| (uint32)((uint32)1U << 17U) /* clock polarity */
| (uint32)((uint32)0U << 16U) /* clock phase */
| (uint32)((uint32)159U << 8U) /* baudrate prescale */
| (uint32)((uint32)8U << 0U); /* data word length */
Thank you for any insight into this problem,
Matthew