Still going ahead with the PIC16F18446...
I'm testing the 12 bits ADC.
First, I had to find out the correspondance between Pin and Channel (I'm using a 20-pin device). Here it is:
The code I use is here:Code:' PIC 16F18446 ' ====== FUSES ===================================================================================== #CONFIG __config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT1 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_ON __config _CONFIG2, _MCLRE_ON & _PWRTS_PWRT_64 & _LPBOREN_OFF & _BOREN_SBOREN & _BORV_LO & _ZCDDIS_OFF & _PPS1WAY_OFF & _STVREN_ON __config _CONFIG3, _WDTCPS_WDTCPS_31 & _WDTE_SWDTEN & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC __config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTD_OFF & _WRTSAF_OFF & _LVP_OFF __config _CONFIG5, _CP_OFF #ENDCONFIG ' ====== REGISTERS ================================================================================= ' Oscillator Control Register1 OSCCON1 = %01100000 ' $60 ' HFFRQ - Oscillator's Frequency Selection Register OSCFRQ = %00000010 ' 4MHz ' ====== DEFINES =================================================================================== DEFINE ADC_BITS 12 'Number of bits in ADCIN result ' ====== VARIABLES ================================================================================= ADC_Value var word Serial_Out VAR PORTB.7 Mode Var BYTE ' ====== INITIALIZE VARIABLES ====================================================================== Mode = 84 ' serial com BdRate settings ' ====== TEST PROGRAM ============================================================================== TEST: ADCIN 23, ADC_Value ' ADC channel 23 is RC7 Serout2 Serial_Out,Mode,["ADC in: ", dEC ADC_Value,13,10] PAUSE 500 GOTO TEST END
Now, the strange thing is: where I expect a 12 bits result (0..4095), I get a 16 bits value 0..65520 as result and it's amazingly steady, not a digit variation!!!
I'm using a 10 turns 10kOhms pot and that's all.
How can that be please?![]()





Bookmarks