Menu

ADC channel 19 not working in 18FXXK22.dat file

Rikki
2023-10-26
2023-10-26
  • Rikki

    Rikki - 2023-10-26

    I'm attempting to read ADC channel AN19 (via portc.7) on a 18F13k22 chip without success.

    Here is a sample of the code

    dim my_variable as word
    dir portc.7 in
    my_variable = readAD10(AN19)

    readAD(AN19) does not work either

    The same code works fine with ADC channel AN2 via portA.2

    After reading through the 18F13k22 datasheet I tried adding /modifying these lines in the 18f13k22.dat file without success:

    ADC=19
    ADCConstants=AN{0..19} USAGE:AN0..AN19
    added CHS4,ADCON0,6

    While these changes didn't appear to break anything they didn't make ADC channel AN19 work.

    Any help would be appreciated thanks

     
  • Anobium

    Anobium - 2023-10-26

    Is 18F13k22 correct ?

    Ummmm. I do no think the 18F13k22 chip as has AN19... that looks like an error in the DAT non-functional information.

    If my version here: Build 12899. I see ADCConstants AN{0..12} USAGE:AN0..AN12 These constants are the valid ADC constants which should be ADCConstants AN{0..12} USAGE:AN0..AN11

    Where, portc.7 is AN9

     
  • Rikki

    Rikki - 2023-10-26

    Apologies, I downloaded the wrong datasheet (18f2x)
    Tested AN9 via portc.7 and it's working. Apologies for taking up your valuable time.

     

    Last edit: Rikki 2023-10-26
  • Anobium

    Anobium - 2023-10-26

    No problem.

    I recommend always to use PICINFO to open the correct datasheet.

    :-)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.