PIC16F18446 - 12 bits ADC gives 16 bits results!!!!


Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891

    Default PIC16F18446 - 12 bits ADC gives 16 bits results!!!!

    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:
    Name:  small.jpg
Views: 60
Size:  64.3 KB


    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?
    Last edited by flotulopex; - 24th February 2024 at 18:33.
    Roger

Similar Threads

  1. Parity & Stop Bits settings and results
    By svjohngalt in forum Serial
    Replies: 4
    Last Post: - 27th January 2018, 20:16
  2. Replies: 2
    Last Post: - 23rd April 2013, 16:34
  3. Incorrect adc channel bits generated
    By grahamg in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th February 2010, 18:56
  4. DT_INTS-14 /interrupts enable bits / flag bits
    By bogdan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th May 2009, 18:42
  5. parsing adc word into bits
    By GREYBIRDMAN in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th April 2007, 21:08

Members who have read this thread : 10

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts