This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DAC1220 SPI communication

Other Parts Discussed in Thread: TM4C1294NCPDT, DAC1220

I am using DAC1220 with TM4C1294NCPDT.

I want to read Registers of DAC.

I can successfully write and update DAC ouput using SPI commands. But the DAC has only SDIO pin that i have connected SSI3XDATA0 of uC.

void SSI3_init()
{
    //
    // The SSI3 peripheral must be enabled for use.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);

    //
    // For this example SSI3 is used with PortF[3:0].
    //
    //ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    ROM_GPIOPinConfigure(GPIO_PF3_SSI3CLK);
    //ROM_GPIOPinConfigure(GPIO_PF2_SSI3FSS);
    ROM_GPIOPinConfigure(GPIO_PF1_SSI3XDAT0);
   // ROM_GPIOPinConfigure(GPIO_PF0_SSI3XDAT1);


    ROM_GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_0 | GPIO_PIN_3);


    ROM_SSIConfigSetExpClk(SSI3_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0,
                       	   SSI_MODE_MASTER, 100000, 8);

    //
    // Enable the SSI3 module.
    //
    ROM_SSIEnable(SSI3_BASE);
}

But when i read the received data it showing 0 value. Because i haven't have any SSI RX pin. I have also tries to use ROM_SSIAdvModeSet(SSI3_BASE, SSI_ADV_MODE_BI_WRITE); & ROM_SSIAdvModeSet(SSI3_BASE, SSI_ADV_MODE_BI_READ); before writing & reading to SPI but that also not working.

So how can i read & write data using single SSI3XDATA0 pin?

  • Hi Ritesh,

    It is not required to read data from the DAC1220, and in many applications it is not used which simplifies things.  I have seen some systems that bit-bang a GPIO port for communication instead of using an SPI peripheral.  If you want to use the SPI peripheral, then you will need to tie the SDIO pin of the DAC1220 to both the data in and data out pin of the SPI peripheral.  To prevent output pin contention you will either need to disable the SPI peripheral pin when reading from the device, or use a tri-state buffer using GPIO control to disable the output pin on the SPI peripheral when reading from the device.

    Best regards,

    Bob B

  • Hi Bob,

    Thanks for the Reply.

    Actually i am facing problem in writing Registers at initialization. In most of cases write is successful. But in few cases DAC reset successfully but started with default register value. And if manually write SFR register later. this time it writes successfully. 

    Below is my code.

    void SSI3_init()
    {
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    
        ROM_GPIOPinConfigure(GPIO_PF3_SSI3CLK);
        ROM_GPIOPinConfigure(GPIO_PF1_SSI3XDAT0);
    
        ROM_GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_3);
    
        ROM_SSIConfigSetExpClk(SSI3_BASE, ui32SysClock, SSI_FRF_MOTO_MODE_0,
                           	   SSI_MODE_MASTER, 100000, 8);
    
        ROM_SSIEnable(SSI3_BASE);
    
        HWREG(SSI3_BASE + SSI_O_CR0) |= 0x00000080;
    }
    
    void DAC_Initialize(void)
    {
    	ROM_IntMasterDisable();
    
    	ROM_GPIOPinTypeGPIOOutput(DAC_RESET_BASE, DAC_RESET_PIN);
    
    	delay_uSec(20);
    	ROM_GPIOPinWrite(DAC_RESET_BASE, DAC_RESET_PIN,DAC_RESET_LOW); //DAC reset pin
    	delay_uSec(20);
    
    	//RESET Pattern for DAC
    	ROM_GPIOPinWrite(DAC_RESET_BASE, DAC_RESET_PIN,DAC_RESET_HIGH);
    	delay_uSec(300);
    
        ROM_GPIOPinWrite(DAC_RESET_BASE, DAC_RESET_PIN,DAC_RESET_LOW);
        delay_uSec(10);
    
    	ROM_GPIOPinWrite(DAC_RESET_BASE, DAC_RESET_PIN,DAC_RESET_HIGH);
    	delay_uSec(700);
    
    	ROM_GPIOPinWrite(DAC_RESET_BASE, DAC_RESET_PIN,DAC_RESET_LOW);
    	delay_uSec(10);
    
    	ROM_GPIOPinWrite(DAC_RESET_BASE, DAC_RESET_PIN,DAC_RESET_HIGH);
    	delay_uSec(1100);
    
    	ROM_GPIOPinWrite(DAC_RESET_BASE, DAC_RESET_PIN,0x00);
    	delay_uSec(1100);
    
    	ROM_GPIOPinConfigure(GPIO_PF3_SSI3CLK);
    	ROM_GPIOPinTypeSSI(DAC_RESET_BASE, DAC_RESET_PIN); //standard
    }
    
    void DAC_SFR_Initialize(void)
    {
    
    	ssi1.buffer[0] = (COMMAND_REGISTER_WRITE | TOTALBYTES_2 | COMMAND_REGISTER_BYTE1_ADDRESS);
    	ssi1.buffer[1] = (ADPT_DISABLE | DAC_OUTPUT_DEACTIVE_AT_CALIB | RESERVED_BIT | CRST_ENABLE);
    	ssi1.buffer[2] = (RESOLUTION_20BITS | CLR_DATA_REGISTER | DF_BINARY_DATA | DISF_ADAPTIVE_FILTER_DISABLE | 0x01);
    
    	ssi1.length = 3;
    	DAC_SPI_Transmit(ssi1.buffer,ssi1.length);
    
    	delay_mSec(500);
    }
    
    
    void DAC_SPI_Transmit(unsigned char array[], unsigned char total_bytes)
    {
    	unsigned char i = 0;
    
    	HWREG(SSI3_BASE + SSI_O_CR0) |= 0x00000080;
    	for (i = 0; i < total_bytes; i++)
    	{
    		ROM_SSIDataPut(SSI3_BASE,array[i]);
    
    		while(ROM_SSIBusy(SSI3_BASE));
    		delay_uSec(50);
    
    		ROM_SSIDataGet(SSI3_BASE, (uint32_t *)&rcvd_data[i]);
    	}
    	HWREG(SSI3_BASE + SSI_O_CR0) &= ~0x00000080;
    }

    So can you tell me whats the problem in my code. In my design CS is tied to Low. So i need to read register to verify successful write. And if not i want to write again.

  • Ritesh,


    Generally, for communications issues, it helps to have a oscilloscope photo or the output of a logic analyzer to help debug.

    Problems in communications can range from to fast of an SCLK or not having the right version of SPI communication being used (here it should be SCLK dwelling low, and data is clocked in and out at the falling edge of SCLK.

    If you want to read back from the register, show SCLK and DIO in detail with enough to be able to read the transaction. Make sure that you are able to see the bit transactions with the scope or logic analyzer.



    Joseph Wu