Hello
Port 5 is not responding. I have set the compatibility mode for regiseter. at P5.6 and P5.8 is a voltage of 2.5 V created I read from P5.6 and P5.8 a voltage. The function does not work as I expect. I expect to P5.6 ADC_DAT = 0x63FF read at 5V or ADC_DAT = 0x6000 at 0V But, I get at 5V or 0V the same result ADC_DAT = 0x6202 And I dont know how I read the voltage from the P5.6 or P5.8 I must set other register when I chose compatibilty mode ??
Thanks for Your Help
#include <xc167.h> #include <intrins.h> #include <XC16X.h> void init (); int AD_Strom_messung (int kanal); unsigned int Strom_Wert,Strom1,Strom2; int kanal; . . . void main (){ { init (); . . . while(1) { Strom2 = AD_Strom_messung (6); // read P5.6 ====> 15F Strom1 = AD_Strom_messung (8); // read der P5.5 ====> 15E }//end of while }//end of main . . int AD_Strom_messung (int kanal){ ADC_CON = kanal + 0x0080 ; // Select Channel und start Conversion do { }while (ADC_CON & 0x0100);// wait of end Conversion Strom_Wert = ADC_DAT & 1023 ;//read ADRES of ADC_DAT return Strom_Wert; } void init () { ADC_CON1 = 0x0104 ; P5DIDIS = 0xFFFF ; }