This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ADC XC167

Hello
can someone help me
I have the XC167 microcontroller from Infenion and would like to write a simple code.
On the analog input at P5.5 and P5.6 is an analog voltage can be created.
These will then be changed and the stress values should be Strom1 and Strom2 returned.
Unfortunately this does not work and I can not explain why this is.
I get strange values
what i have to change my StartXC167.A66 except ADCDIS EQU 0;
thanks for any help.

#include <xc167.h>
#include <intrins.h>
#include <XC16X.h>

int AD_Strom_messung (int kanal);
void init ();

unsigned int Strom_Wert,Strom1,Strom2;

main ()
.
while (1){
.
.
 Strom1 = AD_Strom_messung (5);
 Strom2 = AD_Strom_messung (6);
.
.
}//ende of while
}//ende of main

void init ()
   {........
P5DIDIS = 0xFFFF ;
.
.
}

int AD_Strom_messung (int kanal){
  ADC_CON = kanal + 0x0080 ;//start the conversion in kanal
 do {

     }while (ADC_CON & 0x0100);//waiting for the conversion

  Strom_Wert = ADC_DAT & 1023 ;// read the result
  return Strom_Wert;
 }

Parents
  • From XC167 errata sheet:

    ADC_X.H1 Polling of Bit ADBSY
    After an A/D conversion is started (standard conversion by setting bit ADST = 1, injected conversion by setting ADCRQ = 1), flag ADBSY is set 5 clock cycles later. When polling for the end of a conversion, it is therefore recommended to check e.g. the interrupt request flags ADC_CIC_IR (for standard conversions) or ADC_EIC_IR (for injected conversions) instead of ADBSY.

Reply
  • From XC167 errata sheet:

    ADC_X.H1 Polling of Bit ADBSY
    After an A/D conversion is started (standard conversion by setting bit ADST = 1, injected conversion by setting ADCRQ = 1), flag ADBSY is set 5 clock cycles later. When polling for the end of a conversion, it is therefore recommended to check e.g. the interrupt request flags ADC_CIC_IR (for standard conversions) or ADC_EIC_IR (for injected conversions) instead of ADBSY.

Children
No data