assemblypicpic18mplab-x

Problem with PIC18F45K50's ANSELE register


I am trying to make a code for PIC18F45K50, I am trying to use PORTE as digital input, that means I have to clear ANSELE register which controls this pin behavior

Working on MPLABX 3.30 i tried this line of code:

clrf ANSELE

to clear the register, and I also tried setting the bits of the register individually, but when testing on MPLABX debugger, no matter what I do, the instruction just doesn't do anything and the code goes on. I wish someone can help me or bring me some information about how i can enable this register to be modified in MPLABx

The code im working on is made in ASM


Solution

  • ANSELE has address 0x0F5F so isn't direct addressable because it is not part of access RAM. Check datasheet PIC18(L)F2X/45K50, FIGURE 6-5: DATA MEMORY MAP FOR PIC18(L)F2X/45K50 DEVICES for more information.

    Load first the proper BSR value to access these registers, like:

       MOVLB   high ANSELE 
       CLRF    ANSELE
    

    Or use MPLAB assembler directive like...

       BANKSEL ANSELE 
       CLRF    ANSELE