If you need fast response you can create tables using arrays.
For 4 bit system you have 16 different states, so you create array which hold data for output for every 16 states. And use 4 bits of ports for inputs, and outpust, eg portb0 to Portb3 is inputs, portA0 to 3 are outputs.
TruthTable var byte[16] BANKA'So pbp doesn't need to put banksel after each command
TruthTable[0]=%00001111
TruthTable[1]=%00001100
etc...
TruthTable[15]=%00001111
TRIS...
ANSEL
ETC..
Tmp Var byte BANKA
Main:
Tmp=portb & %00001111
porta=TruthTable[Tmp]
goto Main
This will give almost fastest response for given clock speed.
If you grounded upper nibble, this give you fastest possible responese
Main:
porta=TruthTable[portb]
goto Main
If speed isn't critical you can assign bits to Tmp variable from any pin...




Bookmarks