0

I am trying to make code for PIC18F45K50. I am trying to use PORTE as digital input. That means I have to clear the ANSELE register which controls this pin behavior.

Working on MPLAB X 3.30, I tried this line of code to clear the register:

clrf ANSELE

I also tried setting the bits of the register individually, but when testing in the MPLAB X debugger, no matter what I did, the instruction just didn't do anything and the code went on. How can I enable this register to be modified in MPLAB X?

The code I'm working on is made in assembly language.

2
  • 1
    Try to elaborate what you're trying to do, I mean what do you expect that the code does, also add your implementation. Commented May 21, 2023 at 8:20
  • Your MPLABx is pretty old. It' not the issue, but maybe update to v5.3. And please show more code. Commented May 22, 2023 at 7:17

1 Answer 1

3

ANSELE has address 0x0F5F, so it isn't directly addressable, because it is not part of accessing RAM.

Check the datasheet for PIC18(L)F2X/45K50, FIGURE 6-5: DATA MEMORY MAP FOR PIC18(L)F2X/45K50 DEVICES for more information.

First load the proper BSR value to access these registers, like:

   MOVLB   high ANSELE
   CLRF    ANSELE

Or use an MPLAB assembler directive like...

   BANKSEL ANSELE
   CLRF    ANSELE
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.