已回答假定已回答

AD7190BRUZ 多通道切换读取通道顺序问题

hf_xyz@163.com 在 2016-4-6 詢問的問題
最後回覆由hpkamen於2016-4-7提供

1、2、3三个电压读取通道,写入0xXX70XX,使能AIN1-AINCOM,AIN2-AINCOM,AIN3-AINCOM.

但是通道1、2、3读取顺序无法控制,上电后第一次读取顺序是1、2、3,后面再读取时就变成2、3、1或者3、1、2..............了

 

// initial ADC , select channel 1

void init_adc(void)

{

  ADC_WR_8Byte(0x08); //All communications to the part must start with a write operation to the communications register,set next operation as a write to the Mode register

  ADC_WR_24Byte(0x00018); //write Mode register /*--select external clock---*/

  ADC_WR_8Byte(0x10); //All communications to the part must start with a write operation to the communications register,set next operation as a write to the Configuration register

  ADC_WR_24Byte(0x7008);////write Configuration register /*--select AI1--AICOM, unipolar---*/

  ADC_WR_8Byte(0x5C); // continuously  read data

// GPIO_ResetBits(GPIOC , GPIO_Pin_1);//din=0

}

 

if(string_point==5)//"WM"

    {

   NVIC_DisableIRQ(USART1_IRQn);

   if(HandleFlag) 

     {

  init_adc();

  Delay(0x0010);

  for(i=0;i<50;i++)

    {

  rev_v[i*3] = get_adc(); //读取电压值

  rev_v[i*3+1] = get_adc(); //读取电压值

  rev_v[i*3+2] = get_adc(); //读取电压值

    }

  for(i=0;i<150;i++)

  printf("%f\r\n",rev_v[i]);

     }

}

 

float get_adc(void)

{

    uint8_t   adc_res[3]={0};

  uint32_t    conv;

    float   temp;

    while(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_0)== 1);   // wait for convert

 

  ADC_RD_24Byte(3,adc_res);

   conv = (adc_res[0] << 16)+(adc_res[1] << 8)+adc_res[2];

  

  temp = (float)conv*0.000244140625/*(4096>>24)*/;

  temp = temp*4.1/4096;

      return temp;

}

結果