Yup,
I can give the ASM answer, but you’ll have some lookup work to do..
and this might not work.. I’ll try to point out the difficult spots as we go.
Download the microchip datasheet for the chip you are using..PIC18F452 or whichever.
Download the MIOS function reference..
Find the MIOS code to turn OFF analog multiplexing.. add that to your program. MIOS_AIN_UNMUXED??
It would be great to turn off MIOS analog stuff completely.. not sure how, but someone will chime in.
In the datasheet, read up on configuring the analog inputs as analog or digital. THis may be a problem..
You can select how many are analog and how many are digital, but it’s not a free form assignment.
Usually, if you want just one analog input, it MUST be A0.. there is no option for making A0 digital and a2 analog, for instance. the exception is that one of those analog inputs may be re-assigned as a reference, but that doesn’t help us.
In the end, the ADCON0 and ADCON1 registers will control which pins are analog and which are digital.
Then you can set bits in the TRISA register to split the digital pins into inputs (1) and outputs(0)
Then you can set LATA bits to determine which outputs are HIGH (1) or Low(0).
note: for the top three analog inputs, that will be TRISE and LATE, as they are in port E instead of A
All of these can be set/reset/played with “live” while the program is running, if need be. I do NOT know what it will take to get MIOS to leave these alone. Obviously if it is scanning any analog inputs at all, then you may have to deal with that..
Note that using I/O pins to supply +5 and Gnd will not work if current requirements get near 20ma.. although you can get a FEW more ma than that, it will drop the voltage as you get near the limits.
I think once all the details are worked out, you’ll find it easier to wire up each side individually and not try swapping pin meanings from X to Y, if that is possible at all.
That way you could avoid all this mucking around and get on to the fun stuff.
Have Fun, (or.. Good Luck??)
LyleHaze