Please stay on topic.
Here's a summary: I have two pesky devices in my circuit. A multiplexer and a decoder.The multiplexer is connected as:
notice how the selection channels are on consecutive pins thus making things easy for selecting the channels:Code:MUX '------------ 'RA5 INH 'RA1 A 'RA2 B 'RA3 C 'RA4 D '------------
On the other hand the decoder pins are scattered across PORT B and PORTC:Code:'mux channel selection 'low inh_mux 'for i= 0 to 15 ' Porta = (Porta & %11000001 ) + (i *2) 'port masking for cycle purposes 'next i
here's the code i've devised:Code:'DCD '---------- 'RE2 G1,G2 'RB7 A 'RB6 B 'RB5 C 'RC6 D
The PORTB pins selection works fine (meaning lines A, B and C of the decoder behave as I expected). But line D (the only one on PORTC) gives me a headache. Am I missing something in the mask ?Code:'dcd channel selection low g_dcd for i=0 to 15 portb = (portb & %00011111 ) + (i rev 3)<<5 portc = (portc & %10111111 ) + (i<<3) next i
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
I've tried to do something like that before. If I remember right, the fact that i.3 is a bit didn't work well with the << 6. It ended up shifting itself out into nowhere and always ended up being a '0'.
Maybe that was back in the day, in an older version of PBP or something. It just seems to me like that didn't work very well.
Hi,
I did at test on the breadboard this morning ...
Everything fine ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
This is the winner:I've tried both in MPLAB SIM butCode:portb = (portb & %00011111 ) | ( ( i rev 3 ) << 5 ) portc = (portc & %10111111 ) | ( i.3 << 6 )
doesn't mask the port right.Code:portc = (portc & %10111111 ) | ( i << 3 )
THANK YOU. Problem solved
Good news !
Just for the fun ...
How many boards saved ???
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks