Part Number: ADS1220
Tool/software: Code Composer Studio
Dear
I try to get the sensor data from ADS1220 by SPI Communication on DRV8301-HC-EVM.
I modified the SPI-A Port (J8) of the DRV8301-HC-EVM. First remove the chip U5 and connect the wire to the ADS1220 Module.
I sent the command to the ADS1220. It works and response. But, I can not read the conversion data. There is nothing on DOUT channel from Slave.
What is the problem?
Below the captured image.
CCS Codes
=======================
void HAL_setupSpiA(HAL_Handle handle)
{
HAL_Obj *obj = (HAL_Obj *)handle;
SPI_reset(obj->spiAHandle); // Reset SPI
SPI_setClkPolarity(obj->spiAHandle,SPI_ClkPolarity_OutputRisingEdge_InputFallingEdge);
SPI_disableLoopBack(obj->spiAHandle);
SPI_setCharLength(obj->spiAHandle,SPI_CharLength_8_Bits);
SPI_setTriWire(obj->spiAHandle, SPI_TriWire_NormalFourWire);
// SPI_setTriWire(obj->spiAHandle, SPI_TriWire_ThreeWire);
SPI_setMode(obj->spiAHandle,SPI_Mode_Master);
SPI_setClkPhase(obj->spiAHandle,SPI_ClkPhase_Normal);
// SPI_setClkPhase(obj->spiAHandle,SPI_ClkPhase_Delayed);
SPI_enableTx(obj->spiAHandle);
SPI_enableChannels(obj->spiAHandle);
SPI_enableTxFifoEnh(obj->spiAHandle);
SPI_enableTxFifo(obj->spiAHandle);
SPI_setTxDelay(obj->spiAHandle,0);
SPI_clearTxFifoInt(obj->spiAHandle);
SPI_enableRxFifo(obj->spiAHandle);
// BaudRate setting is not needed for slave mode
// 4MHz for Turbo Mode 2KSPS, so SPIBRR = 21, 4MHz
SPI_setBaudRate(obj->spiAHandle,(SPI_BaudRate_e)(0x0015)); // 0001 0101 --> 101, 5MHz
SPI_setSuspend(obj->spiAHandle,SPI_TxSuspend_free);
SPI_enable(obj->spiAHandle); // Enable SPI
return;
} // end of HAL_setupSpiA() function
============================================================
if((bCfgRegs == false) && (bStartSync == false))
{
switch(addrCfgReg){
case 0:
{
// WR, CFG0, AIN1-AIN2, Gain 128, Enable low-noise PGA
spiTxCmdCFG(0x40); // 0100 0000
spiTxCmdCFG(0x3E); // 0011 1110
addrCfgReg++;
break;
}
case 1:
{
// WR, CFG1, 2KSPS, Turbo mode, Continuous mode, Off Temp Sensor, Off Current Source
spiTxCmdCFG(0x44); // 0100 0100
spiTxCmdCFG(0xD4); // 1101 0100, Turbo Mode
// spiTxCmdCFG(0xC4); // 1100 0100. Normal Mode
addrCfgReg++;
break;
}
case 2:
{
// WR, CFG2, Vref AIN0-AIN3, Off FIR, Off PSW, Off IDAC
spiTxCmdCFG(0x48); // 0100 1000
spiTxCmdCFG(0x80); // 1000 0000
addrCfgReg++;
break;
}
case 3:
{
// WR, CFG3, Off IDAC1, Off IDAC2, On DOUT/DRDY
spiTxCmdCFG(0x4C); // 0100 1100
// spiTxCmdCFG(0x02); // 0000 0010, On DOUT/DRDY
spiTxCmdCFG(0x00); // 0000 0000, Off DOUT/DRDY
addrCfgReg = 0;
bCfgRegs = true;
break;
}
==================================================
void spiTxCmdCFG(uint16_t data)
{
HAL_Obj *obj = (HAL_Obj *)halHandle;
// reset the Rx fifo pointer to zero
// SPI_resetRxFifo(obj->ads1220.spiHandle);
// SPI_enableRxFifo(obj->ads1220.spiHandle);
uint16_t spiCmdReg;
spiCmdReg = data; //Reset
SPI_write8(obj->ads1220.spiHandle, spiCmdReg);
// Clear SPI Interrupt flag
SPI_clearTxFifoInt(obj->ads1220.spiHandle);
return;}