I am using PIC 18F2420 and windows 10 GCB installed from GCB_Installer-98_1.exe.
After some consideration, and trial and error, I found my problem to be caused by when I added
ReadAD(AN0) to my code. So I looked at the Assembler code added by GCB.
That starts:
;Overloaded signature: BYTE:
FN_READAD15
It seems to me that code
a) starts by setting all possible analogue input pins to analogue mode.
b) connects the required one to the ADC
c) Appropriate delay, Trigger ADC, await result etc.
d) return all pins to digital mode.
All very well if you want to make it "automatic" so the user does not need to set up the pin as analogue input before calling ReadAD().
BUT
In my case where I am using some PORTB pins as digital input, and using the External Interrupt fuction and IOC PORTB function on these inputs, AND the PORTB internal pull ups, it causes a problem.
Swiching these pins to analogue mode turns off the internal pull up, and consequently the interrupts on these pins are triggered.
I had to make my own little ReadAD() function ommitting parts a) and d).
Maybe you could put a line in the ReadAD() documentation to highlight that this unintended effect can occur.
I am using PIC 18F2420 and windows 10 GCB installed from GCB_Installer-98_1.exe.
After some consideration, and trial and error, I found my problem to be caused by when I added
ReadAD(AN0) to my code. So I looked at the Assembler code added by GCB.
That starts:
;Overloaded signature: BYTE:
FN_READAD15
It seems to me that code
a) starts by setting all possible analogue input pins to analogue mode.
b) connects the required one to the ADC
c) Appropriate delay, Trigger ADC, await result etc.
d) return all pins to digital mode.
All very well if you want to make it "automatic" so the user does not need to set up the pin as analogue input before calling ReadAD().
BUT
In my case where I am using some PORTB pins as digital input, and using the External Interrupt fuction and IOC PORTB function on these inputs, AND the PORTB internal pull ups, it causes a problem.
Swiching these pins to analogue mode turns off the internal pull up, and consequently the interrupts on these pins are triggered.
I had to make my own little ReadAD() function ommitting parts a) and d).
Maybe you could put a line in the ReadAD() documentation to highlight that this unintended effect can occur.
The ADC routines can be optimised. Did you try this?