I am trying to drive an SPI serial DAC from SPI1 of a C6748 DSP on a Zoom EVM. I am using DSP BIOS 5, psp 1.30.00.05 with edma lld 1.10.00.01.
I have managed to provide clock, data & chip select signals using the SPI psp in interrupt mode but, because the device requires 24 bits of data, there are gaps in the chip select where the signal is deactivated.
I am now attempting to use the edma API to try to overcome this. I have modified the example program provided with the psp utimately using GIO_write or GIO_submit to send the data. When using GIO_submit with a callback the callback is never reached and hence the semiphore always times out. In both cases, write or submit, no signals are seen at the device.
The following shows parts of the relevant code:
void start_spi_sample()
{
GIO_Attrs gioAttrs = GIO_ATTRS;
Spi_ChanParams chanParams;
/* if the edma support is required then we need to configure edma */
EDMA3_DRV_Result edmaResult = 0;
if (NULL == hEdma[0])
{
edmaResult = edma3init();
if (EDMA3_DRV_SOK != edmaResult)
{
/* Error in configuring the edma driver */
LOG_printf(&trace,"\r\nEDMA3 : edma3init() failed\r\n");
}
else
{
LOG_printf(&trace,"\r\nEDMA3 : edma3init() passed\r\n");
}
}
chanParams.hEdma = hEdma[0];
spiParams.edmaHandle = hEdma[0];
/* create SPI channel for transmission */
spiHandle = GIO_create("/Spi1",IOM_INOUT,NULL,&chanParams,&gioAttrs);
hCBSemHandle = SEM_create(0,NULL);
if (NULL != spiHandle)
{
TxCallback.fxn = (GIO_TappCallback)&Spi1TxCallBack;
TxCallback.arg = NULL;
resetDAC();
directWriteSetDAC();
while(1)
{
spi_Test();
}
}
else
{
LOG_printf(&trace,"\r\n SPI Driver Handle creation Failed ");
}
return;
}
/*
* \fn static Int spi_Test(Error_block *eb)
*
* \brief function That will test the SPI device by reading and writing from the
* SPI flash device.
*
* \param eb [OUT] error block given by the upper layers
*
* \return
* DriverTypes_Completed - if sucessful
* Error code - in case of error
*/
void spi_Test()
{
DACout( 0,50.0 );
}
Void Spi1TxCallBack( Void )
{
SEM_postBinary( hCBSemHandle );
}
void WriteDAC( long data )
{
Spi_DataParam dataparam;
size_t size;
Int ret;
outDac[0] = data&0xff;
outDac[1] = (data&0xff00)>>8;
outDac[2] = (data&0xff0000)>>16;
dataparam.bufLen = 3;
dataparam.inBuffer = NULL;
dataparam.outBuffer = &outDac[0];
dataparam.flags &= ~(Spi_CSHOLD|Spi_GPIO_CS); //no CSHOLD or GPIO CS
dataparam.dataFormat = Spi_DataFormat_1;
dataparam.chipSelect = 1<<SPI1_DAC_CS;
size = dataparam.bufLen;
GIO_submit(spiHandle, IOM_WRITE, &dataparam, &size, &TxCallback );
// while (SEM_pendBinary( hCBSemHandle,0 )==FALSE);
// GIO_write(spiHandle, &dataparam, &size );
SEM_pendBinary( hCBSemHandle,10 );
}
void DACout( int axis,float demand )
{
long tmpDemand;
long DACdata;
tmpDemand = (unsigned int)(demand*32767.0F/100.0F + 32767.0F);
tmpDemand = tmpDemand<0 ? 0 : tmpDemand;
tmpDemand = tmpDemand>65535 ? 65535 : tmpDemand;
DACdata = tmpDemand;
DACdata += (long)(0x18 + axis)<<16;
WriteDAC( DACdata );
}
void spi_initParams(void)
{
spiParams = Spi_PARAMS;
spiParams.hwiNumber = 8;
spiParams.spiHWCfgData.intrLevel = FALSE;
spiParams.opMode = Spi_OpMode_DMAINTERRUPT;
spiParams.outputClkFreq = 4000000;
spiParams.loopbackEnabled = FALSE;
spiParams.edmaHandle = NULL;
spiParams.spiHWCfgData.masterOrSlave = Spi_CommMode_MASTER;
spiParams.spiHWCfgData.pinOpModes = Spi_PinOpMode_SPISCS_4PIN;
spiParams.spiHWCfgData.configDatafmt[0].charLength = 16;
spiParams.spiHWCfgData.configDatafmt[0].clkHigh = TRUE ;
spiParams.spiHWCfgData.configDatafmt[0].lsbFirst = FALSE;
spiParams.spiHWCfgData.configDatafmt[0].oddParity = FALSE;
spiParams.spiHWCfgData.configDatafmt[0].parityEnable = FALSE ;
spiParams.spiHWCfgData.configDatafmt[0].phaseIn = FALSE ;
spiParams.spiHWCfgData.configDatafmt[0].waitEnable = FALSE;
//spiParams.spiHWCfgData.configDatafmt[0].wdelay = 0;
spiParams.spiHWCfgData.configDatafmt[1].charLength = 8;
spiParams.spiHWCfgData.configDatafmt[1].clkHigh = TRUE ;
spiParams.spiHWCfgData.configDatafmt[1].lsbFirst = FALSE;
spiParams.spiHWCfgData.configDatafmt[1].oddParity = FALSE;
spiParams.spiHWCfgData.configDatafmt[1].parityEnable = FALSE ;
spiParams.spiHWCfgData.configDatafmt[1].phaseIn = FALSE ;
spiParams.spiHWCfgData.configDatafmt[1].waitEnable = FALSE;
spiParams.spiHWCfgData.configDatafmt[1].wDelay = 0;
spiParams.spiHWCfgData.intrLevel = TRUE;
/* power on the spi device in the Power sleep controller */
Psc_ModuleClkCtrl(Psc_DevId_1, CSL_PSC_SPI1, TRUE);
/* enable the EDMA in the PSC module */
Psc_ModuleClkCtrl(Psc_DevId_0, CSL_PSC_CC0, TRUE);
Psc_ModuleClkCtrl(Psc_DevId_0, CSL_PSC_TC0, TRUE);
Psc_ModuleClkCtrl(Psc_DevId_0, CSL_PSC_TC1, TRUE);
Psc_ModuleClkCtrl(Psc_DevId_1, CSL_PSC_CC1, TRUE);
Psc_ModuleClkCtrl(Psc_DevId_1, CSL_PSC_GPIO, TRUE);
}
void configureSpi1(void)
{
Uint32 savePinmux5 = 0;
/* Unlock BOOTCFG module before pinmux configuration */
KICK0 = KICK0_UNLOCK_CODE;
KICK1 = KICK1_UNLOCK_CODE;
/* enable the pinmux registers for Spi */
/* Only ENA, CLK, SIMO and CS0 are used */
savePinmux5 = (sysCfgRegs->PINMUX5 &
~(CSL_SYSCFG_PINMUX5_PINMUX5_3_0_MASK |
CSL_SYSCFG_PINMUX5_PINMUX5_7_4_MASK |
CSL_SYSCFG_PINMUX5_PINMUX5_11_8_MASK|
CSL_SYSCFG_PINMUX5_PINMUX5_19_16_MASK |
CSL_SYSCFG_PINMUX5_PINMUX5_23_20_MASK));
sysCfgRegs->PINMUX5 = (PINMUX5_SPI1_ENABLE | savePinmux5);
}
Ha anyone seen something like this with the SPI psp before? Any help on this would be appreciated.