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.

ADS1255: DOUT始终无输出

Part Number: ADS1255

程序初始化后主控每10ms向ADS1255发送一次读寄存器指令,从示波器可观测到正确发送了波形,同时ADS1255的DRDY引脚可以正常观察到30KHZ的信号,但DOUT引脚始终无输出(无论输入什么指令)。

最初的问题是发现无源晶振无法正常起振,多次更换晶振型号和起振电容无果后,改为飞线接入7.68MHz有源晶振,可观测到正确晶振波形。

随后发现DOUT始终无应答。下附各SPI引脚工作情况:

从图像可得出信息:主控可以正确的控制SCLK(500KHz)、MOSI(已经校对过指令)、CS引脚发送信号,DOUT始终无输出。

随后尝试取下DOUT与主控之间100Ω电阻,直接测量ADS1255各个引脚,结果发现其他SPI引脚均收到了取信号,但DOUT仍然无输出。

打值测量ADS1255各引脚供电均符合预期,AGND与DGND共地良好,AGND上电后与主控最远的DGND(USB金属外壳)之间有0.06V~0.01V间变化的压差,但应该不至于产生严重影响。

下附原理图与周边pcb布局:

目前XTAL1已更改为7.68MHz有源晶振输入,XTAL2无连接;

C20已更改为10uF。

软件SPI相关代码如下:

#include"ADS1255_NRF_DRV.h"

//SPIÇý¶¯³ÌÐòʵÀýID,IDºÍÍâÉè±àºÅ¶ÔÓ¦£¬0:SPI0  1:SPI1 2:SPI2
#define SPI_INSTANCE  0 

static const nrf_drv_spi_t SPI0 = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE); 
 
//SPI
static volatile bool spi_xfer_done;  

static uint8_t    spi_tx_buf[6];  

static uint8_t    spi_rx_buf[6];  

#define NRF_ADS1255_SPI0_CFG                           \
{                                                            \
    .sck_pin      = NRF_GPIO_PIN_MAP(0,19),                \
    .mosi_pin     = NRF_GPIO_PIN_MAP(0,17),                \
    .miso_pin     = NRF_GPIO_PIN_MAP(0,15),                \
    .ss_pin       = NRF_GPIO_PIN_MAP(1,21),                \
    .irq_priority = SPI_DEFAULT_CONFIG_IRQ_PRIORITY,         \
    .orc          = 0xFF,                                    \
    .frequency    = NRF_DRV_SPI_FREQ_500K,                     \
    .mode         = NRF_DRV_SPI_MODE_1,                      \
    .bit_order    = NRF_DRV_SPI_BIT_ORDER_MSB_FIRST,         \
}


//    .sck_pin      = NRF_GPIO_PIN_MAP(0,19),                
//    .mosi_pin     = NRF_GPIO_PIN_MAP(0,17),                
//    .miso_pin     = NRF_GPIO_PIN_MAP(0,15),                
//    .ss_pin       = NRF_GPIO_PIN_MAP(0,21),                

void Spi_WriteOneByte(uint8_t Dat)
{   
	  spi_tx_buf[0] = Dat;
	  spi_xfer_done = false;
	  SPI0_CS_LOW;
	  APP_ERROR_CHECK(nrf_drv_spi_transfer(&SPI0, spi_tx_buf, 1, spi_rx_buf, 0));
    while(!spi_xfer_done);
	  SPI0_CS_HIGH;
}

/*****************************************************************************
** Ãè  Êö£ºÐ´ÈëÒ»¸ö×Ö½Ú
** ²Î  Êý£ºDat£º´ýдÈëµÄÊý¾Ý
** ·µ»ØÖµ£ºÎÞ
******************************************************************************/
uint8_t SPI_Receive_Send(nrf_drv_spi_t SPIx, uint8_t Data)
{
	  spi_tx_buf[0] = Data;
		spi_rx_buf[0] = 0;
	  //spi_xfer_done = false;
	  SPI0_CS_LOW;
		nrf_delay_us(1);
	  nrf_drv_spi_transfer(&SPIx, spi_tx_buf, 1, spi_rx_buf, 1);
    //while(!spi_xfer_done);
		nrf_delay_us(2);
	  SPI0_CS_HIGH;
		return spi_rx_buf[0];

}


/*****************************************************************************
** Ãè  Êö£ºSPIʼþ´¦Àíº¯Êý
** ²Î  Êý£ºÎÞ
** ·µ»ØÖµ£ºÎÞ
******************************************************************************/

void spi_event_handler(nrf_drv_spi_evt_t const * p_event,
                       void *                    p_context)
{
  //
	spi_xfer_done = true;
}
/*****************************************************************************
** Ãè  Êö£ºÅäÖÃÓÃÓÚÇý¶¯ADS1255µÄ¹Ü½Å
** Èë  ²Î£ºÎÞ
** ·µ»ØÖµ£ºÎÞ
******************************************************************************/
void SPI0_Init(void)
{
    //
	  nrf_gpio_cfg_output(SPI_SS_PIN);

	  //
	  SPI0_CS_HIGH;
	  //
	  nrf_drv_spi_config_t spi_config = NRF_ADS1255_SPI0_CFG;
	  //
//    spi_config.ss_pin   = NRF_DRV_SPI_PIN_NOT_USED;
//    spi_config.miso_pin = SPI_MISO_PIN;
//    spi_config.mosi_pin = SPI_MOSI_PIN;
//    spi_config.sck_pin  = SPI_SCK_PIN;
	  //³õʼ»¯SPI
    APP_ERROR_CHECK(nrf_drv_spi_init(&SPI0, &spi_config, NULL, NULL));
}


//ADS1255¶Á¼Ä´æÆ÷
uint8_t ADS1255_Read_REG(uint8_t Address)
{
  char temp=0;
  unsigned char i;
	SPI0_CS_LOW;
	for(i=0;i<10;i++){};
	SPI_Receive_Send(SPI0,Address|ADS1255_RREG); //
	nrf_delay_us(10);
  //for(i=0;i<10;i++);
	SPI_Receive_Send(SPI0,0x00);         //
	nrf_delay_us(10);                      //
  temp = SPI_Receive_Send(SPI0,0x00);
 	return temp;
}

//ADS1255д¼Ä´æÆ÷
void ADS1255_Write_REG(uint8_t Address,uint8_t data)
{
  unsigned char i;	
	uint8_t cmd[3]={0x00,0x00,0x00,};
	SPI0_CS_LOW;
	cmd[0]=ADS1255_WREG|Address;
	cmd[1]=0x00;
	cmd[2]=data;
  for(i=0;i<10;i++);
	SPI_Receive_Send(SPI0,cmd[0]); //
  for(i=0;i<10;i++);
  SPI_Receive_Send(SPI0,cmd[1]);
  for(i=0;i<10;i++);
  SPI_Receive_Send(SPI0,cmd[2]);
}



void ADS1255_Init(void)   //ADS1255 ³õʼ»¯
{
	SPI0_CS_LOW;
	  
	nrf_delay_us(100);
	while(ADS_DRDY);
	SPI_Receive_Send(SPI0,ADS1255_SELFCAL);      //
	SPI_Receive_Send(SPI0,ADS1255_RESET);
	nrf_delay_us(10);
	
//  while(ADS_DRDY);                                                            
//	SPI_Receive_Send(SPI2,ADS1255_SYNC);                 //
//	SPI_Receive_Send(SPI2,ADS1255_WAKEUP);               //
	
	while(ADS_DRDY);                                                  //
	
	ADS1255_Write_REG(ADS1255_STATUS,0x00);                               //
//	ADS1255_Write_REG(ADS1255_MUX,ADS1255_MUXP_AIN1|ADS1255_MUXN_AINCOM);   //
	ADS1255_Write_REG(ADS1255_ADCON,ADS1255_GAIN_1|0x20);                 //
	ADS1255_Write_REG(ADS1255_DRATE,ADS1255_DRATE_7500SPS);                // 
	ADS1255_Write_REG(ADS1255_IO,0x00);                                   //
	nrf_delay_us(100);
	
	while(ADS_DRDY);                               
	SPI_Receive_Send(SPI0,ADS1255_SELFCAL);              //
	SPI_Receive_Send(SPI0,ADS1255_SYSOCAL); 
	SPI_Receive_Send(SPI0,ADS1255_SYSGCAL); 
	
	SPI0_CS_HIGH;
	nrf_delay_us(10);
}




/********************************************END FILE*******************************************/

(很抱歉没有注释,中文从keil复制过来全是乱码,我不得不把他们删掉)

主函数:

int main(void)
{
	uint8_t cr;

    gpio_output_voltage_setup_3v3();
    log_init();
    uart_config();

	SPI0_Init();
	
	printf("SPI0\n");
	
	
	ADS1255_Init();

		while(true)  
	{  

//    while (app_uart_get(&cr) != NRF_SUCCESS);
//    while (app_uart_put(cr) != NRF_SUCCESS);
    //printf("%c",cr);
		cr = ADS1255_Read_REG(ADS1255_STATUS);
		printf("%c",cr);
		
		nrf_delay_ms(10);
//		if(!ADS_DRDY)
//		{
//			SPI_Receive_Send(SPI0, 0x00);
//			cr = SPI_Receive_Send(SPI0,0x00);
//			printf("%c",cr);
//		}
		
		
		
	}

目前怀疑:

1、驱动代码有问题。

2、芯片坏了/焊接问题。但目前焊接了3块,症状均相同,概率很小。

3、pcb布局问题,但感觉布局的瑕疵不至于对数字信号产生致命影响。