Byron, Could you please translate this into C for me? Thanks, rich! On 9/14/2015 11:14 AM, Byron Jeff wrote: > Richard, > > Your description below screams table. Since it's only 2 bits, the table > would be 4 entries long: > > TableA: ; W is input. Returns table entry in W. > andlw 0x3 ; make sure only 2 lowest bits are used > addwf PC,F ; jump to appropriate table entry > retlw 0x82 ; return 1001 in bits 7-6,3-2 if input is 00 > retlw 0x04 ; return 0010 in bits 7-6,3=3D2 if input is 01 > retlw 0x40 ; return 0100 in bits 7-6,3=3D2 if input is 10 > retlw 0x80 ; return 1000 in bits 7-6,3=3D2 if input is 11 > > Make a similar table for B. > > Then all you'd need to do is read the port, clear the output bits, call t= he > table routine, OR back in the results, and write the whole mess back to t= he > port. > > Hope this helps, > > BAJ > > On Mon, Sep 14, 2015 at 10:31:15AM -0500, Richard R. Pope wrote: >> Jan-Erik, >> I guess my next question is about packing the register. The RA0-1 >> and RB0-1 bits are my inputs. On Port A the output pins are 2-3 and 6-7. >> On Port B it is 2-5. So if I have two output registers. One called >> OutputA and the other OutputB. When the input is 0-0 then the output is >> 1-0-0-1. If the input is 0-1 then the output is 0-0-1-0. If it is 1-0 >> the output is 0-1-0-0 and if it is 1-1 the the output is 1-0-0-0. I >> guess we should define some constants called Bit# such as Bit0, Bit1, >> Bit2 and so forth to Bit7. These should be set to 1, 2, 4, 8, and so >> forth up to 128. We first have to clear the registers to zero with >> OutputA or B =3D 0; So do we add RA, B 0 and 1 together? And here is whe= re >> I get lost. I just don't understand how to turn RA and B 0 and 1 in to >> the proper number to put into the output bits. Would you please help me >> with this. >> Thanks, >> rich! >> >> P.S. This is how it should look. >> --------------------------------- ---------------------------------- >> | Input | Output | >> | Input | Output | >> | Bits | Bits PortA | >> | Bits | Bits PortB | >> |-----|-----|-----|-----|-----|-----| >> |-----|-----|-----|-----|-----|------| >> | 1 | 0 | 2 | 3 | 6 | 7 | >> | 1 | 0 | 2 | 3 | 4 | 5 | >> |-----|-----|-----|-----|-----|-----| >> |-----|-----|-----|-----|-----|------| >> | 0 | 0 | 1 | 0 | 0 | 1 | >> | 0 | 0 | 1 | 0 | 0 | 1 | >> |-----|-----|-----|-----|-----|-----| >> |-----|-----|-----|-----|------|-----| >> | 0 | 1 | 0 | 1 | 0 | 0 | >> | 0 | 1 | 0 | 1 | 0 | 0 | >> |-----|-----|-----|-----|-----|-----| >> |-----|-----|-----|-----|------|-----| >> | 1 | 0 | 0 | 0 | 1 | 0 | >> | 1 | 0 | 0 | 0 | 1 | 0 | >> |-----|-----|-----|-----|-----|-----| >> |-----|-----|-----|-----|------|-----| >> | 1 | 1 | 0 | 0 | 0 | 1 | >> | 1 | 1 | 0 | 0 | 0 | 1 | >> |-----|-----|-----|-----|-----|-----| >> |-----|-----|-----|-----|------|-----| >> Thanks, >> rich! >> >> >> On 9/13/2015 6:00 AM, Jan-Erik S=F6derholm wrote: >> >> --=20 >> http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .