Other Parts Discussed in Thread: DAC60508
Hi, I am trying to transmit 24bit data. Since the data size is bigger than 16bit, I am trying to split it into 8bit and send them seperately.
Like, if transmit data is 010203, then it is transmitted 01,02,03.
I am worried if the data is overwritten or dropped and also I am sure that I set spiTransaction.count parameter right.
But I have a trouble in sending data. my code is attached below, so could you check if my code is right?
typedef union Txdata{
uint32_t DAC;
uint8_t transbuffer[4];
}Txdata;
SPI_Handle spiHandle;
SPI_Params spiParams;
SPI_Transaction spiTransaction;
Txdata txdata;
uint32_t transmitBuf;
bool TransOK;
/* Call driver init functions */
SPI_init();
/*initialize SPI parameters*/
SPI_Params_init(&spiParams);
spiParams.dataSize=8;//8-bit data size
spiHandle=SPI_open(Board_SPI_DAC,&spiParams);
if (spiHandle == NULL) {
/* SPI_open() failed */
while (1);
}
//Fill in transmitBuffer
spiTransaction.count=3;
transmitBuf=0x010888;//010FFF;
txdata.DAC=transmitBuf;
int i;
while(1)
{
TransOK=1;
for(i=0;i<3;i++)
{
spiTransaction.txBuf=txdata.transbuffer+i;
TransOK = SPI_transfer(spiHandle,&spiTransaction);
if (!TransOK) {
// Error in SPI or transfer already in progress
}
}
}