TI中文支持网
TI专业的中文技术问题搜集分享网站

DAC60508: SPI按规格书写了数据,为何无电压输出。

Part Number:DAC60508

我按照DateSheet上输出控制,第三个通道,为何无电压输出。

原理图如下:

SPI控制时序如下:

使用万用表测量发现无电压输出,如下:

#define NOOP_ADDRESS		((uint8_t)0x00)

#define DEVICE ID_ADDRESS	((uint8_t)0x01)

/* 3 SYNC register address */
#define SYNC_ADDRESS		((uint8_t)0x02)/* SYNC default (reset) value */
 #define SYNC_DEFAULT		((uint16_t)0xFF00)
 
/* 4 GAIN register address */
#define GAIN_ADDRESS		((uint8_t)0x04)

/* 5 TRIGGER register address */
#define TRIGGER_ADDRESS		((uint8_t)0x05)

/* 6 BRDCAST register address */
#define BRDCAST_ADDRESS		((uint8_t)0x06)

/* 7 STATUS register address */
#define STATUS_ADDRESS		((uint8_t)0x07)
 
/* 8 DAC ͨ����ַ */ 
typedef enum
{
	DAC0_ADDRESS	= 0x08,
	DAC1_ADDRESS	= 0x09,
	DAC2_ADDRESS	= 0x0A,
	DAC3_ADDRESS	= 0x0B,
	DAC4_ADDRESS	= 0x0C,
	DAC5_ADDRESS	= 0x0D,
	DAC6_ADDRESS	= 0x0E,
	DAC7_ADDRESS	= 0x0F
} DAC_CH_ADDRESS;

void TI_DAC60508_Setup(void);

void DAC60508_WriteDate(DAC_CH_ADDRESS ch, uint16_t wdate);

void DAC60508_SetVoltage(DAC_CH_ADDRESS ch, float voltage);



#include "dev_dac60508.h"

void TI_DAC60508_Setup(void)
{
	SPI1Init(SPI_MODE3);
}

void DAC60508_WriteDate(DAC_CH_ADDRESS ch, uint16_t wdate)
{
	uint8_t date[3];
	uint8_t rdate[3];
	
	date[0] = (uint8_t)ch;
	date[1] = (uint8_t)(wdate>>8);
	date[2] = (uint8_t)wdate;
	
	SPI1ReadWriteBuffer(&rdate[0], &date[0], 3);
}

void DAC60508_SetVoltage(DAC_CH_ADDRESS ch, float voltage)
{
	uint16_t code;
	code = voltage/2.5*0x1000;	
	DAC60508_WriteDate(ch, code);
}



#include "dev_dac60508.h"

int main(void)
{
	HalInit();		// CPU内部接口初始化
	TI_DAC60508_Setup();
	
	while(1)
	{
		DAC60508_WriteDate(DAC3_ADDRESS, 500);
		DelayMs(500);
		DAC60508_WriteDate(DAC3_ADDRESS, 1000);
		DelayMs(500);
		DAC60508_WriteDate(DAC3_ADDRESS, 1500);
		DelayMs(500);
		DAC60508_WriteDate(DAC3_ADDRESS, 2000);
		DelayMs(500);
		DAC60508_WriteDate(DAC3_ADDRESS, 2500);
		DelayMs(500);
		DAC60508_WriteDate(DAC3_ADDRESS, 3000);
		DelayMs(500);
		DAC60508_WriteDate(DAC3_ADDRESS, 3500);
		DelayMs(500);
		DAC60508_WriteDate(DAC3_ADDRESS, 4000);
		DelayMs(500);
	}
	
	return 1;
}

请问哪里配置有问题?

Amy Luo:

您好,

DAC60508的SDI是在SCLK的下降沿采样,因此主控端输出的数据需在SCLK的下降沿保持稳定,看您时序图主控端是在SCLK的下降沿改变输出数据,因此可能是这里的问题,您先修改下这里看是否正常输出?

,

wang chenmeng:

你好罗工,我改好了,如下图。

目前读写寄存器均没问题,就是无电压输出,请问硬件和软件哪里还有问题。

软件代码请见附件。读配置寄存器,除了DeviceID 外,其它的全部是0x0000

#ifndef __DEV_DAC60508_H__
#define __DEV_DAC60508_H__#include "hal.h"#define NOOP_ADDRESS((uint8_t)0x00)#define DEVICE_ID_ADDRESS	((uint8_t)0x01)/* 3 SYNC register address */
#define SYNC_ADDRESS((uint8_t)0x02)/* SYNC default (reset) value */#define SYNC_DEFAULT((uint16_t)0xFF00)/* 4 Conigure register address */
#define CONFIG_ADDRESS((uint8_t)0x03)/* 5 GAIN register address */
#define GAIN_ADDRESS((uint8_t)0x04)/* 6 TRIGGER register address */
#define TRIGGER_ADDRESS((uint8_t)0x05)/* 6 BRDCAST register address */
#define BRDCAST_ADDRESS((uint8_t)0x06)/* 7 STATUS register address */
#define STATUS_ADDRESS((uint8_t)0x07)/* 8 DAC ͨ����ַ */typedef enum
{DAC0_ADDRESS	= 0x08,DAC1_ADDRESS	= 0x09,DAC2_ADDRESS	= 0x0A,DAC3_ADDRESS	= 0x0B,DAC4_ADDRESS	= 0x0C,DAC5_ADDRESS	= 0x0D,DAC6_ADDRESS	= 0x0E,DAC7_ADDRESS	= 0x0F
} DAC_CH_ADDRESS;void TI_DAC60508_Setup(void);uint16_t DAC60508_ReadDate(uint8_t address);void DAC60508_WriteDate(DAC_CH_ADDRESS ch, uint16_t wdate);void DAC60508_SetVoltage(DAC_CH_ADDRESS ch, float voltage);#endif#include "dev_dac60508.h"void TI_DAC60508_Setup(void)
{uint16_t chipID;uint16_t sync_date;uint16_t config;uint16_t gain;uint16_t trigger;uint16_t brdcast;uint16_t status;uint8_t rdate[3];SPI1Init(SPI_MODE1);chipID = DAC60508_ReadDate(DEVICE_ID_ADDRESS);sync_date = DAC60508_ReadDate(SYNC_ADDRESS);config = DAC60508_ReadDate(CONFIG_ADDRESS);gain = DAC60508_ReadDate(GAIN_ADDRESS);trigger = DAC60508_ReadDate(TRIGGER_ADDRESS);brdcast = DAC60508_ReadDate(BRDCAST_ADDRESS);status = DAC60508_ReadDate(STATUS_ADDRESS);
}uint16_t DAC60508_ReadDate(uint8_t address)
{uint8_t tdate[3] = {0x00, 0x00, 0x00};uint8_t rdate[3] = {0x00, 0x00, 0x00};uint16_t rxdate = 0x0000;tdate[0] = address;SPI1_CSN_IO_LOW;//Ƭѡ����rdate[0] = SPI1ReadWriteByte(tdate[0]);DelayUs(2);SPI1_CSN_IO_HIGH;//Ƭѡ����SPI1_CSN_IO_LOW;//Ƭѡ����SPI1ReadWriteBuffer(&rdate[1], &tdate[1], 2);DelayUs(2);SPI1_CSN_IO_HIGH;//Ƭѡ����rxdate = ((uint16_t)rdate[1] << 8) + rdate[2];return rxdate;
}void DAC60508_WriteDate(DAC_CH_ADDRESS ch, uint16_t wdate)
{uint8_t tdate[3] = {0x00, 0x00, 0x00};uint8_t rdate[3] = {0x00, 0x00, 0x00};tdate[0] = (uint8_t)ch;tdate[1] = (uint8_t)(wdate>>8);tdate[2] = (uint8_t)wdate;SPI1_CSN_IO_LOW;//Ƭѡ����SPI1ReadWriteBuffer(&rdate[0], &tdate[0], 3);DelayUs(2);SPI1_CSN_IO_HIGH;//Ƭѡ����
}void DAC60508_SetVoltage(DAC_CH_ADDRESS ch, float voltage)
{uint16_t code;code = voltage/2.5*0x1000;DAC60508_WriteDate(ch, code);
}uint16_t dac_date[8];int main(void)
{HalInit();// CPU内部接口初始化while(1){DAC60508_WriteDate(DAC0_ADDRESS, 500);dac_date[0] = DAC60508_ReadDate(DAC0_ADDRESS);DAC60508_WriteDate(DAC1_ADDRESS, 1000);dac_date[1] = DAC60508_ReadDate(DAC1_ADDRESS);DAC60508_WriteDate(DAC2_ADDRESS, 1500);dac_date[2] = DAC60508_ReadDate(DAC2_ADDRESS);DAC60508_WriteDate(DAC3_ADDRESS, 2000);dac_date[3] = DAC60508_ReadDate(DAC3_ADDRESS);DAC60508_WriteDate(DAC4_ADDRESS, 2500);dac_date[4] = DAC60508_ReadDate(DAC4_ADDRESS);DAC60508_WriteDate(DAC5_ADDRESS, 3000);dac_date[5] = DAC60508_ReadDate(DAC5_ADDRESS);DAC60508_WriteDate(DAC6_ADDRESS, 3500);dac_date[6] = DAC60508_ReadDate(DAC6_ADDRESS);DAC60508_WriteDate(DAC7_ADDRESS, 4000);dac_date[7] = DAC60508_ReadDate(DAC7_ADDRESS);memset(&dac_date[0], 0x00, sizeof(dac_date));}return 1;
}

,

Amy Luo:

SPI接口电平是否与主控端电平电容:

内部基准电压实测是多少? 是2.5V吗?

上电后,建议您进行 Software Reset:

SCLK速率是多少?输出一个sample后,是否进行了延迟?看您最新的时序图只进行了三个无效字节的时间:

建议您先输出一个固定电平看是否可以实现?

您是进行的写操作,不知道为什么MISO上有输出?

输出负载是什么?断开输出负载输出结果怎样?注意下设置输出在其输出范围:

,

wang chenmeng:

1、SPI时序电平是 3.3V;2、基准使用内部基准,测得的电压是 2.5V;

3、SCK的速率是 1MHz;

4、三个MOSI无效字节是读寄存器;

5、负载为空,我焊个电阻在试试。

,

wang chenmeng:

1、写了Soft Reset后输出电平还是0V

2、我焊上1K的负载,输出电平还是0V

,

Amy Luo:

关于您的问题,您是仅第三通道异常?还是仅测试了第三通道异常,其他通道正常吗?

读寄存器 bit23应是高电平,且cs要保持24周期的SCLK的低电平:

另外,寄存器写入后是否可以正确读出来?

,

wang chenmeng:

所有通道都测过,一样的。

,

wang chenmeng:

把CS拉长到,效果也一样。SPI写一个DA值,在读一个DA值,是正确的。

还是无输出

,

Amy Luo:

读寄存器也是24bit 为一帧,如下读时序图截图,您按照下面时序读寄存器,是否也可以正确读出写入值?

,

wang chenmeng:

可以

,

Amy Luo:

wang chenmeng said:读配置寄存器,除了DeviceID 外,其它的全部是0x0000

SYNC寄存器不应该是0,其默认值是0xFF00:

另外我注意到,您写入的二进制code与对应的十进制不一致,因为 DAC60508是12bit DAC,寄存器是16bits ,因此寄存器的低4位没有用。十进制500对应二进制是0x1F4,那么写入寄存器就是0x1F40,而不是0x01F4:

我想是不是这个原因造成没有输出的,毕竟如果按照您使用的方法写入,最大输出是0xFF,对应的模拟输出是0.15V左右,相对来说比较小。

,

wang chenmeng:

奇怪的是,我读01-07寄存器全部是 0x0000

,

wang chenmeng:

该不会是电路或者器件有问题吧!

,

Amy Luo:

您的意思是上电后读取寄存器01-07值都是0x0000?您上电后,执行下Soft Reset后再读取寄存器值,DEVICEID 和 SYNC 寄存器还是0吗?

也就是说现在您写入寄存器后可以正确读出来,但是上电后读取默认值不正确?您尝试了几块板子是这种现象?建议您多尝试几块板子以排除焊接问题;

您使用的芯片型号后缀是Z还是M的?

所使用芯片是从TI store 或TI代理商处购买的吗

赞(0)
未经允许不得转载:TI中文支持网 » DAC60508: SPI按规格书写了数据,为何无电压输出。
分享到: 更多 (0)