DAC81416: dac81416无法写入通道输出DACx data register寄存器

Part Number: DAC81416

尊敬的技术大大们好!我遇到的情况是这样子的,软件复位以后,往SPI_CONFIG寄存器写入数值0x0004,我们可以看到正常的数值0x0004,意味着器件已经脱离低功耗模式。同时我尝试读取REG_DEVICEID也可以读取到正确的版本信息,这证明我的SPI读写应该是配置正确了。以下这是我的SPI配置,它应该没有错
static void MX_SPI1_Init(void)
{

  /* USER CODE BEGIN SPI1_Init 0 */

  /* USER CODE END SPI1_Init 0 */

  /* USER CODE BEGIN SPI1_Init 1 */

  /* USER CODE END SPI1_Init 1 */
  /* SPI1 parameter configuration*/
  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_MASTER;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
  hspi1.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN SPI1_Init 2 */

  /* USER CODE END SPI1_Init 2 */
}
我的问题是,当我往DACx data register寄存器写入数值的时候总是无效,只能读取到0x0000
    cs_sw(chipIndex);
    dac_writeReg(0x0E, 0x000A);
    HAL_Delay(5);
    dac_writeReg(R_SPICONFIG, 0x0004);    
    uart2_printf("delayreg:%x\r\n",dac_readReg(R_SPICONFIG));
    uart2_printf("id:%x\r\n",dac_readReg(0x01));
    {
        cs_sw(chipIndex);
        
        dac_writeReg(R_DACRANGE0, 0x0000);
        dac_writeReg(R_DACRANGE1, 0x0000);
        dac_writeReg(R_DACRANGE2, 0x0000);
        dac_writeReg(R_DACRANGE3, 0x0000);
        dac_writeReg(R_DACPWDWN, 0x0000);
        dac_writeReg(R_GENCONFIG,0x0400);
        dac_writeReg(R_BRDCONFIG, 0x0000);
        dac_writeReg(R_SYNCCONFIG,0x0000);
        dac_writeReg(0x10, 0x6666);
        dac_writeReg(R_DACPWDWN, 0x0000);
    }
我在1秒定时器里头添加了写完再读寄存器输出的代码,但是读取到的数值一直为0
void Timer2_Callback(TIM_HandleTypeDef* htim)
{
    (void)htim;
    static uint8_t toggleF = 0;
    toggleF ^= 0x01;
    HAL_GPIO_WritePin(powderBlueLED_GPIO_Port, powderBlueLED_Pin, (toggleF==0x00)?GPIO_PIN_RESET:GPIO_PIN_SET);
    //dac_init(&hspi1);
    uint8_t index = 0;
    cs_sw(0);//im sure it points to the cs pin im using
    for(index = 0;index < 16;index++)
    {        
        dac_writeReg(0x10+index, 0x6666);
        uart2_printf("0x%x:0x%x\r\n",0x10+index,dac_readReg(0x10+index));
    }
}

另外在软件复位前spiconfig寄存器一直无法正常写入,读取到的数值一直是0x0aa4,往TRIGGER register(offset = 0x0E)使能SOFT-RESET就可以解决,我看到好像没有人遇到这样子的问题,所以我顺带记录在这里希望可以帮到某些朋友。

  • gpt translate:
    Hello respected technical experts! Here's the situation I'm encountering: After a software reset, when I write the value 0x0004 to the SPI_CONFIG register, we can see the normal value 0x0004, indicating that the device has exited low-power mode. Additionally, when I try to read REG_DEVICEID, I can get the correct version information, which proves that my SPI read/write configuration should be correct. Below is my SPI configuration, which should be error-free.
    static void MX_SPI1_Init(void)
    {

      /* USER CODE BEGIN SPI1_Init 0 */

      /* USER CODE END SPI1_Init 0 */

      /* USER CODE BEGIN SPI1_Init 1 */

      /* USER CODE END SPI1_Init 1 */
      /* SPI1 parameter configuration*/
      hspi1.Instance = SPI1;
      hspi1.Init.Mode = SPI_MODE_MASTER;
      hspi1.Init.Direction = SPI_DIRECTION_2LINES;
      hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
      hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
      hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
      hspi1.Init.NSS = SPI_NSS_SOFT;
      hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
      hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
      hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
      hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
      hspi1.Init.CRCPolynomial = 10;
      if (HAL_SPI_Init(&hspi1) != HAL_OK)
      {
        Error_Handler();
      }
      /* USER CODE BEGIN SPI1_Init 2 */

      /* USER CODE END SPI1_Init 2 */
    }

    My issue is that when I write values to the DACx data register, it's always ineffective, and I can only read back 0x0000.
      cs_sw(chipIndex);
        dac_writeReg(0x0E, 0x000A);
        HAL_Delay(5);
        dac_writeReg(R_SPICONFIG, 0x0004);    
        uart2_printf("delayreg:%x\r\n",dac_readReg(R_SPICONFIG));
        uart2_printf("id:%x\r\n",dac_readReg(0x01));
        {
            cs_sw(chipIndex);
            
            dac_writeReg(R_DACRANGE0, 0x0000);
            dac_writeReg(R_DACRANGE1, 0x0000);
            dac_writeReg(R_DACRANGE2, 0x0000);
            dac_writeReg(R_DACRANGE3, 0x0000);
            dac_writeReg(R_DACPWDWN, 0x0000);
            dac_writeReg(R_GENCONFIG,0x0400);
            dac_writeReg(R_BRDCONFIG, 0x0000);
            dac_writeReg(R_SYNCCONFIG,0x0000);
            dac_writeReg(0x10, 0x6666);
            dac_writeReg(R_DACPWDWN, 0x0000);
        }

    void Timer2_Callback(TIM_HandleTypeDef* htim)
    {
        (void)htim;
        static uint8_t toggleF = 0;
        toggleF ^= 0x01;
        HAL_GPIO_WritePin(powderBlueLED_GPIO_Port, powderBlueLED_Pin, (toggleF==0x00)?GPIO_PIN_RESET:GPIO_PIN_SET);
        //dac_init(&hspi1);
        uint8_t index = 0;
        cs_sw(0);//im sure it points to the cs pin im using
        for(index = 0;index < 16;index++)
        {        
            dac_writeReg(0x10+index, 0x6666);
            uart2_printf("0x%x:0x%x\r\n",0x10+index,dac_readReg(0x10+index));
        }
    }

    Additionally, before the software reset, the SPI_CONFIG register couldn't be written to properly, and the read value was always 0x0aa4. This issue was resolved by enabling SOFT-RESET in the TRIGGER register (offset = 0x0E). I haven't seen anyone else encounter this kind of problem, so I'm documenting it here in case it helps others.

  • Hi,

    First of all, SPICONFIG whould be 0x0A84 (to power up the DUT) and let's not change the default values. 
    Next DACx data register is only write and can't be read back. Read back data is always zero, we are aware of this mistake and taking corrective action for the same.

    Let me know for any other issues.

  • Thank U,Mr Links!Thank U,really!I checked the datasheet again.It seems the DACx data register can be read back.I downloaded the dataSheet from  ti official web .So it should be the lastest version.
    By the way,I found the DACPWDWN reg keeps value 0x0000 although I have reset the device by writing 0x000A to TRIGGER_REG->SOFTRESET .

    It seems not my software's problem and I would check the hardward connect again.
    And thank u, it help me a lot that make me feel i m not fighting alone .

  • Hello,Mr.Links.I checked the output of DAC81416 .And it's just what you said that the output is OK while the readback data of the DACx data reg is always 0x0000 , unbelievable.There are indeed some errors in the datasheet.Thank you!May your days be filled with the symphony of laughter and joy, and may your kindness in helping others return to you tenfold. Wishing you and your loved ones boundless happiness and countless moments worth cherishing!