Hot!MCC is not generating code to clear ANSEL/ANSELH - 18F26K20

Author
BillE
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2018/02/26 09:48:30
  • Location: 0
  • Status: offline
2018/06/12 15:00:21 (permalink)
0

MCC is not generating code to clear ANSEL/ANSELH - 18F26K20

Using 18F26K20 with XC8 (1.45) and MCC (1.55.1) MPLAB (4.0)
Pin manager does not create code to clear ANSEL or ANSELH for digital operation.
When I set RA0 - RA7 as outputs using the pinmanager I have to manually clear ANSEL registers before they work in digital mode.
Each time I regenerate my project MCC wants to delete my modifications. Am I doing something wrong?
Took a while to discover this - now it is annoying as I can accidentally accept MCC changes and erase ANSEL/ANSELH
#1

5 Replies Related Threads

    jack@kksound
    code tags!
    • Total Posts : 2760
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: online
    Re: MCC is not generating code to clear ANSEL/ANSELH - 18F26K20 2018/06/13 07:42:18 (permalink)
    0
    ANSEL and ANSELH are to set the mode (analog or digital) of the port I/O pins INPUT state, not the OUTPUT state. Pins selected for output mode will always output digital signals. Pins selected as inputs must have the appropriate ANSEL (or ANSELH) bit set or cleared to get analog or digital mode. MCC will clear this bit automatically if an analog capable pin is selected as a digital input (not affected by simply setting the pins as outputs). You may also set/clear these register bits manually in MCC on the pin manager tab under the Registers tab, there you will see the ANSEL and ANSELH registers.
    #2
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: MCC is not generating code to clear ANSEL/ANSELH - 18F26K20 2018/06/13 16:10:38 (permalink)
    +1 (1)
    BillE
    ...
    When I set RA0 - RA7 as outputs using the pinmanager I have to manually clear ANSEL registers before they work in digital mode.

    If they are not working, that means you are incorrectly controlling pins via PORTx registers when you should be using LATx registers.
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #3
    BillE
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/02/26 09:48:30
    • Location: 0
    • Status: offline
    Re: MCC is not generating code to clear ANSEL/ANSELH - 18F26K20 2018/06/13 16:12:04 (permalink)
    0
    Jack,
    Thanks. Think I understand. I made a mistake when I said outputs I meant digital as I was doing a bit-bang stream and could not read the digital in.
    So even if I specify a digital input with the pin manager I need to also explicitly set the pin as digital using one of the predefinitions  e.g. IO_RA0_SetDigitalMode()
    I expected that in the ANSELx registers section of pin_manager.c that the appropriate register would be cleared to override the default analogue setting for the ones I want as digital in. Nothing I do seems to create code in the ANSELx section which is what gave rise to my question. LATx and TRISx get set up fine.
    Once I discovered that my digital input was not working I cleared the appropriate ANSEL/ANSELH bits. I am trying to rework my projects to use MCC wherever possible to move away from 'plib'.
     
     
    #4
    jack@kksound
    code tags!
    • Total Posts : 2760
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: online
    Re: MCC is not generating code to clear ANSEL/ANSELH - 18F26K20 2018/06/14 07:36:15 (permalink)
    0
    With some more testing here it appears you are correct. The Register VIew in MCC under the pin manager shows the selection of inputs and outputs OK, the settings for analog and digital and the wpus however the generated code does NOT have any register assignment statements for the ANSEL/ANSELH registers. I think a support ticket is due here....
    #5
    BillE
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2018/02/26 09:48:30
    • Location: 0
    • Status: offline
    Re: MCC is not generating code to clear ANSEL/ANSELH - 18F26K20 2018/06/15 05:45:52 (permalink)
    0
    Jack,
    Thank you for that. I have learned a lot from these forums and it is great to put something back. I will work my way towards raising a support ticket.
    #6
    Jump to:
    © 2018 APG vNext Commercial Version 4.5