您好!
我正在尝试将 ADS1292与 PSoC 连接、但我无法读取寄存器值(即使 ID 寄存器返回0x00)。
请注意、ADS 在默认配置下工作。 我们在多个 ADS1292芯片上面临这一问题。
以下是我在调试时遵循的步骤:
1.数据表中提到的上电顺序。
2.如 TI 论坛中其他几个问题中所述、增加了延迟。
3.已检查 VCAP1、VCAP2和 Vref 的值。
4.探测 MISO/CS/CSLK/DRDY 线路并在示波器上进行检查。
这是我使用的代码:
初始化
//Defines for Commands. #define WakeUpCmd 0x02 #define StandByCmd 0x04 #define ResetCmd 0x06 #define StartCmd 0x08 #define StopCmd 0x0A #define SDATACCmd 0x11 #define RDATACmd 0x12 #define ReadRegCmd 0x20 #define WriteRegCmd 0x40 // Defines for Register Addresses. #define ID_Addr 0x00 #define CONFIG1_Addr 0x01 #define CONFIG2_Addr 0x02 #define CH1SET_Addr 0x04 #define CH2SET_Addr 0x05 #define RLDSENS_Addr 0x06 #define RESP1 0x09 #define RESP2 0x0A
ADS 配置的功能
void my_ads_config(void) { uint8 temp; /*Power UP Sequence*/ Pin_MISO_Write(0); Pin_MOSI_Write(1); Pin_SCLK_Write(0); Pin_DRDY_Write(1); Pin_SS_Write(1); Pin_PWDN_Write(0); Pin_Start_Write(0); /*Wait for Tpor=1s*/ CyDelay(1000); /*Set CLK=1*/ Pin_SCLK_Write(1); /*Wait for Tpor=1s*/ CyDelay(1000); /*RESET PULSE*/ Pin_PWDN_Write(1); CyDelay(1000); Pin_PWDN_Write(0); CyDelay(1000); Pin_PWDN_Write(1); CyDelay(100); /*Reset communication*/ Pin_SS_Write(0); CyDelay(1000); Pin_SS_Write(1); CyDelay(500); /* stop read data continous mode */ SendCommand(SDATACCmd); CyDelay(10); /*Read ID register*/ temp = ReadRegister(0x00); /* using internal buffer*/ WriteRegister(CONFIG2_Addr, 0xA0); CyDelayUs(10); temp = ReadRegister(0x02); SendCommand(StartCmd); }
2.读取寄存器的函数
uint8 ReadRegister (uint8_t ui8RegAddress) { uint8_t tx_buf [3]; uint8_t rx_buf[3]; const uint8_t PACKET_SIZE = 3; Pin_SS_Write(0); /* Send write register command appended with the register address. */ tx_buf[0] = ReadRegCmd | ui8RegAddress; CyDelayUs(5); tx_buf[1] = 0; CyDelayUs(5); tx_buf[2] = 0; CyDelayUs(5); /* start transfer */ SPIM_ads_SpiUartPutArray(tx_buf, PACKET_SIZE); /* wait for the end of the transfer */ while(PACKET_SIZE != SPIM_ads_SpiUartGetRxBufferSize()); Pin_SS_Write(1); /* read RX buffer */ rx_buf[0] = (uint8) SPIM_ads_SpiUartReadRxData(); rx_buf[1] = (uint8) SPIM_ads_SpiUartReadRxData(); rx_buf[2] = (uint8) SPIM_ads_SpiUartReadRxData(); /* clear dummy bytes from RX buffer */ SPIM_ads_SpiUartClearRxBuffer(); /* return the register content */ return(rx_buf[2]); }
3.写入寄存器的函数
void WriteRegister (uint8_t ui8RegAddress, uint8_t ui8RegData) { uint8_t tx_buf [3]; const uint8_t PACKET_SIZE = 3; /* Send write register command appended with the register address. */ tx_buf[0] = WriteRegCmd | ui8RegAddress; CyDelayUs(5); tx_buf[1] = 0; CyDelayUs(5); tx_buf[2] = ui8RegData; CyDelayUs(5); /* start transfer */ SPIM_ads_SpiUartPutArray(tx_buf, PACKET_SIZE); /* wait for the end of the transfer */ while(PACKET_SIZE != SPIM_ads_SpiUartGetRxBufferSize()); /* clear dummy bytes from RX buffer */ SPIM_ads_SpiUartClearRxBuffer(); }