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.

DAC7565: SPI Communication Issue

Part Number: DAC7565

We are trying to integrate the dac 7565 to our microcontroller, we are facing a strange issue with respect to the spi communication, the psuedo code is

static void DacWrite( uint16_t dacChannel, const uint16_t dataToWrite){
uint8_t dacBuffer[3]{0};
HAL_GPIO_WritePin(DAC_ENABLE_GPIO_Port,DAC_ENABLE_Pin,GPIO_PIN_RESET);
uint32_t wrdata = dataToWrite << 4;
dacBuffer[1] = static_cast<uint8_t>((wrdata >> 8) & 0xff);
dacBuffer[2] = static_cast<uint8_t>(wrdata & 0xff);
HAL_GPIO_WritePin(DAC_SYNC_GPIO_Port,DAC_SYNC_Pin,GPIO_PIN_RESET);
DWT_Delay_us(1);
switch (dacChannel) {
  case DAC_CHANNEL_A: 
    dacBuffer[0] = 0x10;    
    break;
  case DAC_CHANNEL_B: 
    dacBuffer[0] = 0x12;
    break;
    case DAC_CHANNEL_C: 
    dacBuffer[0] = 0x14;
    break;
    case DAC_CHANNEL_D: 
    dacBuffer[0] = 0x16;
    break;
default:
return;
break;
}
HAL_SPI_Transmit(&hspi1, dacBuffer, 3, 10000);
HAL_GPIO_WritePin(DAC_SYNC_GPIO_Port,DAC_SYNC_Pin,GPIO_PIN_SET);
HAL_GPIO_WritePin(DAC_ENABLE_GPIO_Port,DAC_ENABLE_Pin,GPIO_PIN_SET);
}


//Calling the dac function in a loop as follows:

for(int i =0;i<3000;i+=100){
    
  DacWrite(DAC_CHANNEL_A,i);
  DacWrite(DAC_CHANNEL_B,i);
  DacWrite(DAC_CHANNEL_C,i);
  DacWrite(DAC_CHANNEL_D,i);
  DelayMs(2000);
  }

The issue we are facing is with this code, only DAC A gets updated, DAC C gets updated with almost twice the values of Dac A and no output in DAC, DAC B and DAC D never gets updated an they are always at 0.

However when code is ran with breakpoints set at each of the DacWrite(..) Statements, the dac output of all the channels are correct. 

Tried other way, where the enable pin is always kept low and sync is made low/high for spi communication, the results are same.