We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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; }
Hello Just Grateful for the quick response I have no power to the P5.5 or P5.6 laid.normally should Strom1 = 0 and Strom2 = 0. But Strom1 and Strom2 get 0 or 128 (0x0080) or 160 (0x00A0) thanks
Hello I have nowhere initialize the ADC. I have just ADC_CON and ADC_DAT initialized
Thanks
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.