Hello,
I'm using TMS320F28335 board with DSP/BIOS. I need to control 2 devices through single SPI. It is arranged such that SPISIMOA and SPICLKA outputs are shared between these two devices. I have a GPIO pin for each device that replaces SPISTEA functionality, so I need to control them manually.
I've been able to make the system work by adding time delay between writing data to SPI and switching PINs but that solution is not elegant and needs tuning with the change of baud rate. Additionally it consumes extra time that can be spent efficiently.
I've tried to do the same with interrupts but no success. I didn't use FIFO buffers in that case, below are the corresponding parts of the code
SpiaRegs.SPICCR.all =0x000F;
SpiaRegs.SPICTL.all =0x000E;
SpiaRegs.SPISTS.all=0x0000;
SpiaRegs.SPIBRR =0x0003;
SpiaRegs.SPIPRI.bit.FREE = 1;
PieCtrlRegs.PIEIER6.bit.INTx1 = 1;
PieCtrlRegs.PIEIER6.bit.INTx2 = 1;
IER |= 0x0020;
Void spi_send(Uint16 a)
{
GpioDataRegs.GPACLEAR.bit.GPIO23 = 1; //enable receive for the 1st device
//---Send data
SpiaRegs.SPITXBUF = a;
SpiaRegs.SPICTL.bit.SPIINTENA = 1;
SEM_pendBinary(&SemSpi, SYS_FOREVER);
GpioDataRegs.GPASET.bit.GPIO23 = 1; //disable receive for the 1st device
GpioDataRegs.GPACLEAR.bit.GPIO19= 1; //enable receive for the 2nd device
//---Send data
SpiaRegs.SPITXBUF = a;
SpiaRegs.SPICTL.bit.SPIINTENA = 1;
SEM_pendBinary(&SemSpi, SYS_FOREVER);
GpioDataRegs.GPASET.bit.GPIO19 = 1; //disable receive for the 2nd device
}
//Serves an interrupt
Void Inter_SPI(Void)
{
SEM_postBinary(&SemSpi);
SpiaRegs.SPICTL.bit.SPIINTENA = 0;
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP6;
}
Are there any suggestions for an elegant solution preferably with FIFO buffers?
Thanks in advance,
Alexander