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.

Data read from DAC5311 from MSP430G2121 is always zero regardless of what input is transmit

Other Parts Discussed in Thread: DAC5311, MSP430G2121

Hello,

Can you pls help to verify the below code to transmit from MSP430 to DAC via SPI.

Task:  to transmit 8-bits data from MSP430 to DAC5311 when there is a change in duty cycle.

Issue: The output of DAC5311 is always reading zero regardless of what input is transmit to DAC5311

 Can you confirm do I need to use USI interrupt service routine?

-----------------------------------
//SJ4060111 - Setting USI
USICTL0 |= USIPE6 + USIPE5 + USILSB + USIMST + USIOE; //SJ4130111 - Port, SPI Master
//USICTL1 |= USIIE; //SJ4130111 - Not sure if we need it.
USICKCTL = USISSEL_2; //SJ4130111 - /1 SMCLK USICTL0 &= ~USISWRST; // USI released for operation


//Transmit to DAC5311
DAC_SYNC_LOW; //SJ4130111 - Set pin 1.4 to low

USISRL = duty_cycle; //init-load data - Low Byte Shift Register //USISRH = ; //High Byte Shift Register USICNT = 8;

DAC_SYNC_HIGH; //SJ4130111 - Set P1.4 high
------------------------------------

 

  • I never worked with the USI, but one thing is common for all SPI implementations: if you de-assert the CS signal (DAC_SYNC_HIGH), this will immediately terminate all SPI transfer (precisely, it will terminate the slave data sending and reception, even if the master continues clocking and bit-shifting). And most likely discard any data or protocol block that hasn't been completely transmitted to the slave.

    Since you just assign your value to USISRL and then de-assert the chip select, the DAC5311 will never receive anything as it will assume it is not the target for the still ongoing transmission. You have to wait until the hardware has transmitted the data before you de-assert the chip select. (check the busy bit of the USI module - I'm sure it has one)

    I haven't checked your SPI init code, so there might be other problems still. From the other USART/USCI modules, I know that you can only configure certain parrts while SWRST is set before (it is set after a reset), and of course you have to clear SWRST before you can operate the module. In your posted code this last step has moved into the comment of the previous line. I hope it isn't in your real code :)

  • someone can provide the sample code of SPI interfacing with DAC5311? MCU is MSP430G2121