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.

ADS1292R: SPI communication init

Part Number: ADS1292R

Hi,

I've been trying to read any kind of data on Dout pin from my ADS1292r and it seems like I don't have any idea what is going on. 

I've been trying to read ID register on 0x00 location. Can u please have a quick look and try to find what am I doing wrong?

Code is compiled and i can get SCLK, DIN and CS_ working properly, ie. I'm getting sclk and DIN on oscilloscope when "send_command" is 

I am using pic24fj64ga104 and only want to read status register at the begining.

Pic SCLK = 1MHz

disclaimer - This is code not inspired all by me!

void initADS1292(){

     inCodeDelayMs(500);//delay miliseconds
      inCodeDelayMs(500);
       
     ADS_CLKSEL = 1; //iternal clock
    //reset ADS1292
    ADS_RESET_OFF;
    inCodeDelayMs(500);
    inCodeDelayMs(500);
    
    
    ADS_RESET_ON;
    inCodeDelayMs(500);
    inCodeDelayMs(500);
    ADS_RESET_OFF;
    inCodeDelayMs(500);
    
            
     
    CS_SELECT;
    inCodeDelayMs(500);
    inCodeDelayMs(500);
    CS_DESELECT;
    
    inCodeDelayMs(500);
      
    
    
    //Send SDATAC command (Stop read data continuosly mode)
    send_command(SDATAC); // #define SDATAC          0x11
    
    inCodeDelayMs(1);
    
    inCodeDelayMs(5);
    
     read_byte(0x00);// read status reg




    int read_byte (int reg_addr) {
    int out=0;
    CS_SELECT; // CS pin = 1
    WriteSPI1 (0x20 | reg_addr);
    TTG_inCodeDelayMs(1);
    WriteSPI1 (0x00); //number of registers to be read/written -1
    TTG_inCodeDelayMs(1);
    out = ReadSPI1();
    TTG_inCodeDelayMs(1);
    CS_DESELECT;//CS pin=0
    return (out);
}
void send_command(uint8_t cmd) {
    CS_SELECT;
    TTG_inCodeDelayMs(2);
    WriteSPI1 (cmd);
    TTG_inCodeDelayMs(2);
    CS_DESELECT; 
}

  • Hi Mate,

    Welcome to our e2e forum! Can you please share your schematic and a picture of what you see on the oscilloscope?
  • Hey Tom, 

    thanks for fast reply, I'm currently at home so I don't have oscilloscope. Will share everything first thing in the morning. Im from Croatia, that's for 12 hours.

    Cheers!

  • Hi, below is whole code for better visualisation I hope. I've tried whole morning to come up with something, even with source code from 
    ADS_1x9x_ECG_recorder_ Firmwire, but I just don't know what is going on

    Sclk is 1MHz and pic clock is 8MHz



    int main(int argc, char** argv) {
        int mate=0;
        EnableWDT(WDT_DISABLE);  
        
        TTG_Configure();
        
           TTG_inCodeDelayMs(500);
           TTG_inCodeDelayMs(500);
           TTG_inCodeDelayMs(500);
           TTG_inCodeDelayMs(500);
           
          
            
          // initADS1292();
        //worker();
        initADS1292();
        while(1){ 
             /* ADS1292_StartC();
            if( ADS_DRDY==0){
                ADS1292_UpdateChannelData();
            }*/
            
            
    
           
           TTG_inCodeDelayMs(500);
           read_byte(0x00);
            mate++;
            mate++;
            mate++;
                    
            /*
            TTG_inCodeDelayMs(200);
        BT_OTA=0;
           TTG_inCodeDelayMs(200);
        BT_OTA=1;*/
        }
    
        return (EXIT_SUCCESS);
    }
    
    void write_byte(unsigned char reg_addr, unsigned char val_hex) {
        CS_SELECT;
        TTG_inCodeDelayMs(1);
        WriteSPI1(0x40 | reg_addr);
        TTG_inCodeDelayMs(1);
        WriteSPI1 (0x00);
        TTG_inCodeDelayMs(1);
        WriteSPI1 (val_hex);
        TTG_inCodeDelayMs(2);
        CS_DESELECT;
    }
    
    unsigned char read_byte (unsigned char reg_addr) {
        int out=0;
        CS_SELECT;
        WriteSPI1 (0x20 | reg_addr);
        TTG_inCodeDelayMs(1);
        WriteSPI1 (0x00); //number of registers to be read/written -1
        TTG_inCodeDelayMs(1);
        out = ReadSPI1();
        TTG_inCodeDelayMs(1);
        CS_DESELECT;
        return (out);
    }
    
    void send_command(unsigned char cmd) {
        CS_SELECT;
        TTG_inCodeDelayMs(2);
        WriteSPI1 (cmd);
        TTG_inCodeDelayMs(2);
        CS_DESELECT; 
    }
    
    void initADS1292(){
        int i;
        
        ADS_RESET_OFF;
        for(i=0;i<5000;i++);//wait 1msec
        ADS_RESET_ON 
        for(i=0;i<5000;i++);//wait 1msec              
        ADS_RESET_OFF;
        for(i=0;i<35000;i++)//wait
        
        
     
                
         
      
        TTG_inCodeDelayMs(500);
          
        
        
        //Send SDATAC command (Stop read data continuosly mode)
        send_command(SDATAC);
                  
       
       /* SPI_in_buff[SPI_in_buff_len++] = (unsigned char)ReadSPI1(); //Read the recieved data from Buffer
      if (SPI_in_buff_len == MAX_IN_SPI)
      {
          SPI_in_buff_len = 0;
      }
        */
        //All GPIO set to output
         
        
        
        
        write_byte(CONFIG1,0x02);//continuous conversion, 500SPS
        
        write_byte(CONFIG2,0xA0);//Vref,CLK_EN as output,test
        TTG_inCodeDelayMs(500);
        write_byte(CONFIG2,0xA3);
        for(i=0;i<5000;i++)//wait 1msec
        TTG_inCodeDelayMs(1);
        write_byte(CH1SET,0x05);
        for(i=0;i<5000;i++)//wait 1msec
        write_byte(CH2SET,0x05);
        for(i=0;i<5000;i++)//wait 1msec
        write_byte(GPIO, 0x00);
        for(i=0;i<5000;i++)//wait 1msec
        write_byte(LOFF,0x10);
        for(i=0;i<5000;i++)//wait 1msec
        write_byte(RLD_SENS,0x00);
        for(i=0;i<5000;i++)//wait 1msec
        write_byte(LOFF_SENS,0x00);
        for(i=0;i<5000;i++)//wait 1msec
        write_byte(LOFF_STAT,0x00);
        for(i=0;i<5000;i++)//wait 1msec
        write_byte(RESP1,0x02);
        for(i=0;i<5000;i++)//wait 1msec
        write_byte(RESP2,0x01);
        
        
        
        }
    

  • Hi Mate,

    I don't immediately see anything in your schematic that would cause a problem. So things to look for though, check and verify AVDD and DVDD against AVSS to be sure you have power. Check and verify the state of CLKSEL and the CLK source, the state of PWDN/RESET, and /CS.
  • Hi Tom,

    Just to let u know, the problem is solved 3 days after..I made a hole with probe from oscilloscope near pin where  my SPI clock was going off so signal never went to ads chip. Jesus :)

    Thanks for reply's!

  • Cool! Thank's for letting us know!