Menu

PIC18F27Q43: #define AD_REF_SOURCE AD_REF_AREF does not set ADREF register

2025-09-18
2025-09-23
  • Nobutarou Nosuke

    Hello,

    I have a trouble with ADC setup for PIC18F27Q43.

    Here is my code,

    #Chip 18f27q43,16
    
    #config LVP = ON
    #config MCLR = ON
    
    #define USART_BAUD_RATE 9600
    #define USART_TX_BLOCKING
    #define USART_DELAY OFF
    RC4PPS = 0x20 ; RC4 -> TX
    
    ; ADC setup
    #define AD_REF_SOURCE AD_REF_AREF
    #define ADSpeed LowSpeed
    dir portb.7 in
    
    Do
      hserprint readad12(anb7)
      HSerPrintCRLF
      wait 1 s
    Loop
    

    I expect that PREF bits in ADREF resister should be set to 0b10. However, I cannot see any ADREF resister operation in the resultant .asm file (attached).

    Am I doing something wrong? or, a bug of GCBasic?

    Thanks

     
  • Anobium

    Anobium - 2025-09-18

    Can you check the Q43 demos. Do those ADC demos work?

    I want to ensure the basics works before we look at the ASM.

    Evan

     
  • Anobium

    Anobium - 2025-09-19

    I meant the basic ADC demos, but, I think you need to use FVRInitialize(). See the Help.

    Evan

     
  • Nobutarou Nosuke

    FVR? ADC basic demo?
    Since I am new to GCBasic and then many things are unknown for me.

    I have just added them manually to make things working,

    ADREF.PREF0 = 0
    ADREF.PREF1 = 1
    

    Thanks,

     
    👍
    1

Log in to post a comment.