Reading a 8bit Binary word
Hi All,
After a little direction here if anyone can help.
What I need to do is read a 8 bit binary word say on porta, look up a value and output this binary value on portb.
But I would need to keep polling the trigger word on porta to see if it changes.
eg 00110011 input
lookup code 00110011 means an output of 11000011 is required.
output 11000011 on portb
keep the output constant until input changes (loop)
In the good old days - i would use a eprom and program it to act as a simple data converter with a bit of discrete logic to track any address changes on the address lines.
Any direction would be great
Many Thanks
Moz
Reading an 8 bit binary word
Hi Dwayne,
Thanks for your help, sorry about the delay in responding I have just got back from London on business.
OK I can follow most of this but dont understand 2 things, why have u declared the variable TranslateData when it does not appear to be used ?
And the other one is
Counter=Counter+2 'Must skip every other byte for table!
On the lookup's this has got me confused.
I did not know you could say read porta as a byte, so i was expecting the code to use a lookup table (if one can hold 38 values) as the input and output data has nothing in common and may in some circumstances be duplicated
eg if input is 11011011 then output 00001100
if input is 00011111 then output 00001100
if input is 10101010 then output 01111111
so i suppose a nasty and not efficient way would be something like this - psuedo code
TRISA="11111111" 'set Porta to all input...8 bit
TRISB="00000000" 'set Portb to all output...8 bit.
ReadData var byte
MainLoop:
ReadData=Porta
If ReadData=11001111 then Gosub SUB1
If ReadData=11001111 then Gosub SUB2
If ReadData=11001111 then Gosub SUB3
Goto MainLoop
SUB1:
Portb=00110100 'outputs to portb
return
SUB2:
Portb=10111000 'outputs to portb
return
SUB3:
Portb=11111100 'outputs to portb
return
It is important to note that there is nothing common between the output and input data.
Thanyou
Moz