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.

AMC7812: seeking support for I2C communication in AMC7812

Part Number: AMC7812

        Hi, I am using a texas based I2C controller AMC7812 for reading ADC values of adc channels in AMC7812. The master controller is AT32UC3a1512 of atmel. I am able to send the I2C commands from master but I am not getting any ack or any data from AMC7812. Kindly suggest me how to get data from AMC7812. I2C mode is enabled by grounding SPI/I2C pin and the slave ID is also selected based upon A0,A1 and A2 pins. Seeking urgent support on this issue.

  • Hi Santosh,

    Can you share your schematic for the configuration? Are you sure the device is powered and configured correctly?

    Thanks,
    Paul
  • I had used the SDA and SCL connection for I2C ; A0, A1and A2 for slave selection and reset pin is given high.
  • Hi Santosh,

    I have a few questions:
    1. Have you confirmed that all the power supply pins are biased correctly? If one of the devices is powered down (IOVDD is 0V), then it could be holding the bus low.
    2. I do not see the source of AVCC on the schematic - can you confirm that it is 5V?
    3. Do you have pull-ups on the I2S lines?
    4. Can you share an oscilloscope capture of the digital communication?

    Thanks,
    Paul
  •  Hi Paul,

    Thanks for the support.

    1. The power supply to ADDD, DVDD and IOVDD is 3.3 V and AVCC1 and AVCC2 is shorted to each other with no external power supply.

    2. Yes pull up to I2C is there to 3.3V through 1K resistor.

    3. Kindly find the required attachment for the wave form. Here I am sending slave id: 0xC2 and resistor address: 0x50 twice and was expecting acknowledgement on SDA. 

  • Hi Santosh,

    This timing looks okay - are you adhering to the required command format for a read?

  • Hi Santosh,

    Any updates?
  • Hi Santosh,

    If you where not able to solve this issue please feel free to respond to this thread, or if the thread is locked, then please create a new thread. I will go ahead and close this issue for now.

    Thanks,
    Paul
  • Hi Paul,
    Sorry for the delay, I had switched to the SPI because I am using AT32UC3a Atmel based controller and there was having some problem in the I2C driver. Now in SPI mode, I am getting all default values of ADC channels also I am able to set the AMC configuration register 0 for ADC internal ADC-REF-INT for getting internal reference to ADC, I can able to read the Read/Write, Address = 4Ch. the value I got is 0x24 for AMC configuration Read/Write, Address = 4Ch. But I am not getting any internal reference value at ADC-REF-OUT. ADC-REF-OUT is giving 0V only. Can you suggest any solution why ADC-REF-INT value is not reflecting at ADC-REF-OUT pin(Pin no 57)????

    Because of no ADC reference value I am not able to get ADC values from any of the ADC channels. Also I had tried by applying external ADC-REF to the ADC-REF-IN, then also I am unable to get ADC channel values.....

  • Hi Santosh,

    You also need to enable the ADC reference buffer and ADC itself in the POWER-DOWN REGISTER (Address 0x6B). Bits 14 enables the ADC, bit 13 enables the reference buffer.

    Set those bits to enable the ADC functions.

    Thanks,
    Paul
  • Hi Paul,

         The above settings help to enable the internal adc reference voltage(2.5v).

    1) But still I am having problem with ICONV bit in AMC configuartion register0. The value of ICONV bit is giving zero although I had set the INCOV bit to 1.

    2) Also i tried to change the AMC configuration register1(0x4D) values  for different adc conversion speed, by setting the CONV-RATE-1 and CONV-RATE-0 values but still I am getting the random values of ADC, not the proper values. Also when, I sets the ADC-REF-INT value in amc configuration register only once, then internal adc reference voltage(2.5v) resets to 0 v after approximately 2-3 minutes, and when I sets this value again and again then the adc reference voltage(2.5v) is maintained.

    3) Also if I am trying to get the values of ADC channel 4, ADC channel 5, adc channel 6, then the value of adc channel 6 is only reflected instead of each adc channels(i.e; only latest asked adc value is reflected instead of each adc's).

  • Hi Santosh,

    The AMC7812 can operate in direct mode or auto mode. In direct mode, setting the ICONV bit will convert all the enabled channels only once, then the ADC will be idle until the next ICONV write. In auto-mode, setting the ICONV will start the ADC, and it will continue reading the ADC until the ICONV bit is written again. Note that ICONV is a self clearing bit, so it will alway read back as 0.

    It seems like you are having a few different issues here. Can you post all your register writes when you configure the device? Are you using the AMC7812EVM?

    Thanks,
    Paul

  • //---------------------------------------------------------------------------------------------------------------------
    //------------------------------ S P I   W R I T E   A N D   R E A D   F U N C T I O N S-------------------------------
    //---------------------------------------------------------------------------------------------------------------------

    void spi_write_1_function()
    {
       if(ADC_Channel_0_Flag==0)
       {
           ADC_Channel_0_Flag=1;
        if(Chip_Select==1)
        {
            spi_set_mode(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,1);
            spi_selectChip(SLAVE_1_SPI,SLAVE_1_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }
        
        if(Chip_Select==2)
        {
            spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,1);
            spi_selectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }
        
        if(Chip_Select==3)
        {
            spi_set_mode(SLAVE_1_SPI,SLAVE_3_SPI_NPCS,1);
            spi_selectChip(SLAVE_1_SPI,SLAVE_3_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }
        
        if(Chip_Select==4)
        {
            spi_set_mode(SLAVE_1_SPI,SLAVE_4_SPI_NPCS,1);
            spi_selectChip(SLAVE_1_SPI,SLAVE_4_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }    
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;
        
        spi_put(SLAVE_1_SPI,0x50);
        
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))
        
        
        ///////////////////////////////////////
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;
        
        spi_put(SLAVE_1_SPI,0x01);
        //spi_put(SLAVE_1_SPI,ADC_Channel_0_Value1);
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))
        ;
        
        
        //////////////////////////////////////
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;

        spi_put(SLAVE_1_SPI,0xff);
        //spi_put(SLAVE_1_SPI,ADC_Channel_0_Value2);
        
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))
        ;
        
        if(Chip_Select==1)
        {    
           spi_unselectChip(SLAVE_1_SPI,SLAVE_1_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
           spi_set_mode(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,0);
        }
        
        if(Chip_Select==2)
        {    
           spi_unselectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
           spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,0);
        }
        
        if(Chip_Select==3)
        {
            spi_unselectChip(SLAVE_1_SPI,SLAVE_3_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
            spi_set_mode(SLAVE_1_SPI,SLAVE_3_SPI_NPCS,0);
        }
        
        if(Chip_Select==4)
        {
            spi_unselectChip(SLAVE_1_SPI,SLAVE_3_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
            spi_set_mode(SLAVE_1_SPI,SLAVE_4_SPI_NPCS,0);
        }
        ADC_Channel_0_Value1=0x00;
        ADC_Channel_0_Value2=0x80;
       }
     
    }



    void spi_write_2_function()
    {
      if(ADC_Channel_1_Flag==0)
        {
         ADC_Channel_1_Flag=1;
        if(Chip_Select==1)
        {
           spi_set_mode(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,1);        
           spi_selectChip(SLAVE_1_SPI,SLAVE_1_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }
        
        if(Chip_Select==2)
        {
           spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,1);        
           spi_selectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }
        
        if(Chip_Select==3)
        {
            spi_set_mode(SLAVE_1_SPI,SLAVE_3_SPI_NPCS,1);
            spi_selectChip(SLAVE_1_SPI,SLAVE_3_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }
        
        if(Chip_Select==4)
        {
            spi_set_mode(SLAVE_1_SPI,SLAVE_4_SPI_NPCS,1);
            spi_selectChip(SLAVE_1_SPI,SLAVE_4_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }    
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;
        
        spi_put(SLAVE_1_SPI,0x51);
        
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))
        
        
        ///////////////////////////////////////
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;
        
        spi_put(SLAVE_1_SPI,0x40);
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))
        ;
        
        
        //////////////////////////////////////
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;

        spi_put(SLAVE_1_SPI,0x00);
        
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))
        ;
        
        if(Chip_Select==1)
        {    
           spi_unselectChip(SLAVE_1_SPI,SLAVE_1_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
           spi_set_mode(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,0);
        }
        
        if(Chip_Select==2)
        {    
           spi_unselectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
           spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,0);    
        }
        
        if(Chip_Select==3)
        {
            spi_unselectChip(SLAVE_1_SPI,SLAVE_3_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
            spi_set_mode(SLAVE_1_SPI,SLAVE_3_SPI_NPCS,0);
        }
        
        if(Chip_Select==4)
        {
            spi_unselectChip(SLAVE_1_SPI,SLAVE_4_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
            spi_set_mode(SLAVE_1_SPI,SLAVE_4_SPI_NPCS,0);
        }    
      }
    }

    void spi_read_function()
    {   
        if(Chip_Select==1)
        {  
           spi_set_mode(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,1);
           spi_selectChip(SLAVE_1_SPI,SLAVE_1_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
        }
        
        if(Chip_Select==2)
        {    
           spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,1);    
           spi_selectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
        }
        
        if(Chip_Select==3)
        {
           spi_set_mode(SLAVE_1_SPI,SLAVE_3_SPI_NPCS,1);    
           spi_selectChip(SLAVE_1_SPI,SLAVE_3_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
        }
        
        if(Chip_Select==4)
        {
           spi_set_mode(SLAVE_1_SPI,SLAVE_4_SPI_NPCS,1);    
           spi_selectChip(SLAVE_1_SPI,SLAVE_4_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=0
        }    
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;
        
        spi_put(SLAVE_1_SPI,ADC_Data_Register);
        // spi_put(SLAVE_1_SPI,0XB0);

                                                
        
        if(ADC_Data_Register==0XB0)  
        {
            ADC_Data_Register=0xA7;    
        }
        
        ADC_Data_Register++;
            
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))
        ;
        

        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;
        
        spi_put(SLAVE_1_SPI,0x00);                        // Dummy Write to Higher Byte
        
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))

        ///////////////////////////////////////////
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;
        
        //Now simply read the data in the receive register
        temp=spi_get(SLAVE_1_SPI);    
        
    //    usart_putchar(EXAMPLE_USART2,(int)2,temp);          
        ///////////////////////////////////////////
        
        spi_put(SLAVE_1_SPI,0x00);                     // Dummy Write to Lower Byte
        
        //Wait for a complete transmission
        while(!spi_is_tx_empty(SLAVE_1_SPI))

        ///////////////////////////////////////////
        
        //Wait for the transmitter to be ready
        while(!spi_is_tx_ready(SLAVE_1_SPI))
        ;
        
        //Now simply read the data in the receive register
        temp2=spi_get(SLAVE_1_SPI);
        

        if(Chip_Select==1)
        {    
            spi_unselectChip(SLAVE_1_SPI,SLAVE_1_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
            spi_set_mode(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,0);
        }
        
        if(Chip_Select==2)
        {    
            spi_unselectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
            spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,0);
        }
        
        if(Chip_Select==3)
        {
            spi_unselectChip(SLAVE_1_SPI,SLAVE_3_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
            spi_set_mode(SLAVE_1_SPI,SLAVE_3_SPI_NPCS,0);
        }
        
        if(Chip_Select==4)
        {
            spi_unselectChip(SLAVE_1_SPI,SLAVE_4_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);   // CS=1
            spi_set_mode(SLAVE_1_SPI,SLAVE_4_SPI_NPCS,0);
        }    
     
            temp=(temp<<8);
            temp=((temp)&(0xff00));
         /*   
            if(Chip_Select==1)
            {
               if(SPI_ADC_0_selection==0)    
               {
                 SPI_ADC_0_selection=1;
                 ADC_channel=0;  
               }
               SPI_ADC_30_selection=0;

            }
                    if(Chip_Select==2)
                    {
                        if(SPI_ADC_10_selection==0)
                        {
                          SPI_ADC_10_selection=1;
                          ADC_channel=10;
                        }
                          SPI_ADC_0_selection=0;
                    }
                            if(Chip_Select==3)
                            {
                               if(SPI_ADC_20_selection==0)
                               {
                                  SPI_ADC_20_selection=1;    
                                  ADC_channel=20;
                               }
                                  SPI_ADC_10_selection=0;
                            }
                                    if(Chip_Select==4)
                                    {
                                        if(SPI_ADC_30_selection==0)
                                        {
                                            SPI_ADC_30_selection=1;
                                        ADC_channel=30;
                                        }
                                        SPI_ADC_20_selection=0;
                                    }
             */

             SPI_ADC[0]=(temp+temp2);

            SPI_ADC[ADC_channel]=(temp+temp2);

            ADC_channel=(ADC_channel+1)%10;                // increment adc channel 4 to 13

         //   usart_write_line(EXAMPLE_USART2,SPI_ADC[ADC_channel]);
         //    usart_putchar(EXAMPLE_USART2,(int)2,temp);
        //     usart_putchar(EXAMPLE_USART2,(int)2,temp2);
        //    usart_putchar(EXAMPLE_USART2,(int)2,temp2);
         //  print(EXAMPLE_USART2,temp2);
            
    }


    void Power_Down_Register()
    {
            if(Power_down_register_flag==0)
            {
                Power_down_register_flag=1;
                
                /////////////////PREF  PADC//////////////////
                
                spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,1);
                
                spi_selectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
                delay_us(1);
                
                
                while(!spi_is_tx_empty(SLAVE_1_SPI))
                ;
                //Wait for the transmitter to be ready
                while(!spi_is_tx_ready(SLAVE_1_SPI))
                ;
                
                spi_put(SLAVE_1_SPI,0x6B);
                
                while(!spi_is_tx_empty(SLAVE_1_SPI))
                ;
                while(!spi_is_tx_ready(SLAVE_1_SPI))
                ;
                
                spi_put(SLAVE_1_SPI,0x60);
                //Wait for a complete transmission
                while(!spi_is_tx_empty(SLAVE_1_SPI))
                ;
                while(!spi_is_tx_ready(SLAVE_1_SPI))
                ;
                
                spi_put(SLAVE_1_SPI,0x00);
                //Wait for a complete transmission
                while(!spi_is_tx_empty(SLAVE_1_SPI))
                ;
                //    while(!spi_is_tx_ready(SLAVE_1_SPI))
                //    ;
                
                spi_unselectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
                spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,0);
                ////////////////////
            }
            
    }

    void AMC_Configuration_Register_0()
    {
            
            if(check_flag==0)
            {
                check_flag=1;
                ////////////////////
                //spi_set_chipselect_delay_bs(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,10000);
                //spi_set_chipselect_delay_bct(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,10);
                //spi_set_delay(SLAVE_1_SPI,10);
                spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,1);
                
                spi_selectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
                delay_us(1);
                
                
                while(!spi_is_tx_empty(SLAVE_1_SPI))
                ;
                //Wait for the transmitter to be ready
                while(!spi_is_tx_ready(SLAVE_1_SPI))
                ;
                
                spi_put(SLAVE_1_SPI,0x4C);
                
                while(!spi_is_tx_empty(SLAVE_1_SPI))
                ;
                while(!spi_is_tx_ready(SLAVE_1_SPI))
                ;
                
                spi_put(SLAVE_1_SPI,0x34);
                //Wait for a complete transmission
                while(!spi_is_tx_empty(SLAVE_1_SPI))
                ;
                while(!spi_is_tx_ready(SLAVE_1_SPI))
                ;
                
                spi_put(SLAVE_1_SPI,0x00);
                //Wait for a complete transmission
                while(!spi_is_tx_empty(SLAVE_1_SPI))
                ;
                //    while(!spi_is_tx_ready(SLAVE_1_SPI))
                //    ;
                
                spi_unselectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
                spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,0);
                ////////////////////
            }
            
    }


    void AMC_Configuration_Register_1()
    {
        
        if(check_flag_2==0)
        {
            check_flag_2=1;
            ////////////////////
            //spi_set_chipselect_delay_bs(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,10000);
            //spi_set_chipselect_delay_bct(SLAVE_1_SPI,SLAVE_1_SPI_NPCS,10);
            //spi_set_delay(SLAVE_1_SPI,10);
            spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,1);
            
            spi_selectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
            delay_us(1);
            
            
            while(!spi_is_tx_empty(SLAVE_1_SPI))
            ;
            //Wait for the transmitter to be ready
            while(!spi_is_tx_ready(SLAVE_1_SPI))
            ;
            
            spi_put(SLAVE_1_SPI,0x4D);
            
            while(!spi_is_tx_empty(SLAVE_1_SPI))
            ;
            while(!spi_is_tx_ready(SLAVE_1_SPI))
            ;
            
            spi_put(SLAVE_1_SPI,0x00);
            //Wait for a complete transmission
            while(!spi_is_tx_empty(SLAVE_1_SPI))
            ;
            while(!spi_is_tx_ready(SLAVE_1_SPI))
            ;
            
            spi_put(SLAVE_1_SPI,0x00);
            //Wait for a complete transmission
            while(!spi_is_tx_empty(SLAVE_1_SPI))
            ;
            //    while(!spi_is_tx_ready(SLAVE_1_SPI))
            //    ;
            
            spi_unselectChip(SLAVE_1_SPI,SLAVE_2_SPI_NPCS);//SPI_SLAVECHIP_NUMBER);
            spi_set_mode(SLAVE_1_SPI,SLAVE_2_SPI_NPCS,0);
            ////////////////////
        }
        
    }

    I am just sending each functions and also send the amc _configuration register_0 command at regular interval of  200msec for setting iconv bit .

    My problem is the i am sending the register value a7 to bo and i also resets the value to a7 by checking but the amc7812 is sending the value of b0 only every time . I want the the value of each register in circular fashion.(note a7 is for spi value of  adc channel4 0x27).

    Kindly help me asap its very urgent.

  • Hi Santosh,

    When the ADC is in auto-mode, the ICONV input acts as a toggle function.  By continuously writing '1' to ICONV, you are enabling the ADC with one command and disabling it on the next command.  You should just write to this register once.

    What register is A7? or B0?  The ADC channels are registers 0x23 to 0x32.

    I think that is your problem.

    thanks,

    paul

  • I had tried this one also, by setting Iconv bit once, but it didn't resolve my problem....A7 is the read register for adc 4 data.(0x27+0x80=0xa7). I just tried with two registers adc 4 and adc 5 and I just want this register in cyclic way to read... But it is not behaving in cyclic manner , instead it gets locked to the adc5 data and continuously giving the value of adc5 data ....
  • Hi Santosh,

    Can you capture the sequence of reads with a digital analyzer or scope to confirm that your addressing scheme is working correctly and you are reading the correct registers?
    Thanks,
    Paul