Hi,
I'm trying to interface my ADS1292 with PSoC, however, I'm not able to read the register values (even the ID register returns 0x00).
Note that the ADS is functioning with default configurations. We're facing this issue with multiple ADS1292 chips.
These are the steps I followed while debugging:
1. Power-up sequence mentioned in the datasheet.
2. Added delay as mentioned in a few other questions in the TI forum.
3. Checked the values of VCAP1, VCAP2, and VRef.
4. Probed the MISO/ CS/SCLK/DRDY lines and checked on the oscilloscope.
This is the code I have used:
0. Initialization
//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
1. Function for ADS Configuration
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. Function to Read Register
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. Function to write register
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(); }