AnsweredAssumed Answered

AD7714 often returns10354846 despite actual signal on the input channel

Question asked by Erylis21 on Apr 4, 2013
Latest reply on May 9, 2013 by RobK

Hi all,

 

Occasionally when reading from my AD7714, I'll get 10354846, even when there is an incredibly small signal on the input.

 

This is what I do:

 

#include "derivative.h"

#include "spi.h"

#include "adc.h"

 

 

char val;

 

 

/************************ Definition writetoreg**************************/

void writetoreg (char val)

{

          char p;

          cs_adc=0;

          p=sendSPI_ch(val);

          cs_adc=1;

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

}

 

 

/************************ Definition read_reg**************************/

 

 

unsigned long read_adc ()

{

          char i;

          volatile unsigned long valeur;

          unsigned char octet1,octet2,octet3;

          cs_adc=0;

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

          {

                    SPI1D=0;

                    while (SPI1S_SPRF==0);                 // On attend que le buffer de reception soit plein

                              if(i==0)

                              {

                                        octet1=SPI1D;

                              }

                              if(i==1)

                              {

                                        octet2=SPI1D;

                              }

                              if(i==2)

                              {

                                        octet3=SPI1D;

                              }

          }

          cs_adc=1;

          valeur=octet1*65536+octet2*256+octet1;

          return(valeur);

}

/************************ Definition init_adc**************************/

 

 

void init_adc (char voie)

{

          char p;

 

          reset=0;

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

          reset=1;

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

 

          if(voie==1)

                    {

                    writetoreg(0x24);

                    writetoreg(0xCF);

                    writetoreg(0x34);

                    writetoreg(0xA0);

                    writetoreg(0x14);

                    writetoreg(0x00);             

                    }

 

          if(voie==2)

                    {

                    writetoreg(0x25);

                    writetoreg(0x4F);

                    writetoreg(0x35);

                    writetoreg(0xA0);

                    writetoreg(0x15);

                    writetoreg(0x00);             

                    }

 

}

 

 

/************************ Definition lire_adc**************************/

 

 

unsigned long lire_adc (char voie)

{

          volatile unsigned long valeur;

          if(voie==1)

                    {

                              while (drdy==0);

                        while (drdy==1);

                        writetoreg(0x5C);

                        valeur=read_adc();

 

                    }

          if(voie==2)

                    {  

                              while (drdy==0);

                              while (drdy==1);

                              writetoreg(0x5D);

                              valeur=read_adc();

                    }

                    return(valeur);

}

#include "derivative.h"

#include "spi.h"

#include "adc.h"

/*****************************************ENVOIE D'UN CHARACTERE****************************************/

 

 

char sendSPI_ch(char carac)

{

 

          while (SPI1S_SPTEF==0);                 // On attend que le buffer d'émission soit vide

          SPI1D=carac;                            // Envoi d'un charactère

 

          while (SPI1S_SPRF==0);                 // On attend que le buffer de reception soit plein

          carac=SPI1D;                           // Récupération d'un charactère

 

          return (carac);

}

 

 

/************************************ENVOIE D'UNE CHAINE DE CHARACTERE***********************************/

 

 

void sendSPI_string(char*chaine)             // l'argument est un pointeur vers un charactère de la chaîne

                    {

          char index=0;

          while(chaine[index]!=0);                  // tant que l'on est pas en fin de chaîne

          {

                    sendSPI_ch(chaine[index]);          // On envoie le charactère pointé par l'index

                    index++;                            // Et l'on incrémente l'index

          }

                    }

 

 

Thanks,

Outcomes