Part Number: TLV5626
Hi Team,
We penetrated TLV5626 to my customer in a new project. Now during debug, customer met issue during SPI configuration. Below is the schematic from customer:
And also below is the C code used by customer:
//---------------------------------------------------------------------------//
// Copyright (c) 2019, NR ELECTRIC Co.,LTD. //
// All rights reserved. //
// //
// FileName : TLV5626.c //
// //
// Title : //
// //
// Description : //
// //
// Original by : //
// //
// //
// Ver | dd mmm yyyy | Author | Description of changes //
// ====|=============|========|=========================================== //
// 0.90| Jan 2019 |zhangjie| //
// //
// //
//---------------------------------------------------------------------------//
//-------------------------------- Include -----------------------------------
#include "board.h"
#include "TLV5626.h"
#include "spi.h"
//-------------------------------- Define -----------------------------------
//---------------------------- Local Variable -------------------------------
//--------------------------- Extern Variable -------------------------------
//---------------------------- Local Function -------------------------------
//--------------------------- Extern Function -------------------------------
//---------------------------------- Code -----------------------------------
/*-----------------------------------------------------------------------------
Function : TLV5626EnableCS
Description : TLV5626ʹ��Ƭѡ
Input : ��
Output : ��
Return : ��
Others :
-----------------------------------------------------------------------------*/
void TLV5626EnableCS(void)
{
selectSpiCs(0);
//Delay time, first SCLK rising edge after CS falling edge, min 30ns
delayNsTimer(50);
}
/*-----------------------------------------------------------------------------
Function : TLV5626DisableCS
Description : TLV5626����Ƭѡ
Input : ��
Output : ��
Return : ��
Others :
-----------------------------------------------------------------------------*/
void TLV5626DisableCS(void)
{
//Delay time, CS rising edge after final SCLK falling edge, min 30ns
delayNsTimer(50);
releaseSpiCs(0);
//tw(CSH) Pulse duration, CS high, min 30ns
delayNsTimer(50);
}
/*-----------------------------------------------------------------------------
Function : initTLV5626
Description : ��ʼ��TLV5626
Input : ��
Output : ��
Return : 0:�ɹ�����0:ʧ��
Others :
-----------------------------------------------------------------------------*/
int initTLV5626(void)
{
Uint8 cmd[2];
Uint8 rcv[2];
int ret;
//slow mode,normal operation,control register,1.024V ref
cmd[0] = CONTROL;
cmd[1] = REF_2048MV_SHIFT;
TLV5626EnableCS();
ret = spiTxRx(0, cmd, rcv, 2);
TLV5626DisableCS();
return ret;
}
/*-----------------------------------------------------------------------------
Function : TLV5626Output
Description : ���TLV5626
Input : data:��ֵ(0-255)
Output : ��
Return : 0:�ɹ�����0:ʧ��
Others :
-----------------------------------------------------------------------------*/
int TLV5626Output(Uint8 data)
{
Uint8 cmd[2];
Uint8 rcv[2];
int ret;
cmd[0] = DAC_CHANNEL_A | FAST_MODE | ((data & 0xF0) >> 4);
cmd[1] = (data & 0x0F) << 4;
TLV5626EnableCS();
ret = spiTxRx(0, cmd, rcv, 2);
TLV5626DisableCS();
return ret;
}
/*-----------------------------------------------------------------------------
Function : setDACOutput
Description : ����DAC�����ѹ
Input : voltage:�����ѹֵ(0~1000mV)
Output : ��
Return : 0 :�ɹ�
-1:��ѹ����ֵ����Χ
-2:DAC���ʧ��
Others :
-----------------------------------------------------------------------------*/
int setDACOutput(Uint16 voltage)
{
Uint16 code;
if(voltage > 1000)
{
return -1;
}
code = (voltage * 0x1000)>>(1+REF_2048MV_SHIFT);
if(TLV5626Output((Uint8)(code>>4)) == 0)
{
return 0;
}
else
{
return -2;
}
}
//End of File
Customer just need to use DAC A output, so they are trying to use the operation example 1 showed in TLV5626's datasheet in page 12(as below, step 1 and step 2):
The issue customer met is that after they write TLV5626 by using above 1 and 2 step, they still can't get output on DAC A. But if they repeat step 2 for one more time, they can get the right output on DAC A. They met this strange issue every time they want to configure output DAC A.
Can you help check what's wrong with the code to cause this strange issue? Another question is that if customer don't need to use DAC B, normally they can just follow step 1 and step 2 as showed above to get DAC A, correct? Or customer have to configure both DAC A and DAC B even one of them is not used?
Best regards,
Sulyn

