Indirect memory access to read ports
Posted: Mon Dec 09, 2019 8:55 am
Hi
Some assistance pls:
For the first time I have tried to obtain the value of registers PORTA and PORTB using indirect memory access, but I do not get the values back which I expect.
I am using an 18F27K40.
The value obtained in variable res is always 0.
Does the value in the register of PORTA or PORTB actually update only when a read is done on that port directly, such as i = PORTA?
I am missing something?
Any suggestions, please?
Using the FSR approach to update ports LATA and LATB work as expected.
Regards
Bernard
Some assistance pls:
For the first time I have tried to obtain the value of registers PORTA and PORTB using indirect memory access, but I do not get the values back which I expect.
I am using an 18F27K40.
Code: Select all
Dim portNumber, res as byte
portNumber = 1
FSR2 = $0F8D + portNumber '$0F8D is the register address of PORTA (as per my understanding of the datasheet),
'add one for PORTB
res = INDF2
Does the value in the register of PORTA or PORTB actually update only when a read is done on that port directly, such as i = PORTA?
I am missing something?
Any suggestions, please?
Using the FSR approach to update ports LATA and LATB work as expected.
Regards
Bernard