I created a circuit like the following:
I have sub-circuits that all take serial data as input and do miscellaneous processing with it. Most of the sub-circuits are just light displays. I want to control such circuits with one microcontroller with simple code.
For simplicity, lets assume all these sub-circuits have no option for a data reset and that the only inputs allowed to them are clock and data into 74HC164's of each sub-circuit. I have illustrated that on the right-hand side of the shown circuit.
Due to PCB wiring and such, I ended up connecting pins 4 and 5 of the 74HC138 decoder to the TXD line which (according to several resources can function as a clock in serial mode 0). I connected pin 6 to a GPIO pin in an attempt to prevent false alarms.
What I want to do in software is to easily select any one device and send data to it preferably with the fewest instruction cycles as possible.
Because serial port mode 0 for 8051 is a good candidate, I thought about it by using code like this:
mov P1,#8Fh ;use 1st device
clr TI
mov SBUF,A ;A=8 bits of data
jnb TI,$ ;wait for full transmission
mov P1,#9Fh ;use 2nd device
clr TI
mov SBUF,A ;A=8 bits of data
jnb TI,$ ;wait for full transmission
clr TI
mov SBUF,A ;A=8 bits of data
jnb TI,$ ;wait for full transmission - here we sent 16 bytes to device 2.
That's the kind of code I ultimately like to use, but I feel theres a slight problem because if I'm not mistaken, one document online claimed the TXD line goes from low to high when it signals data is ready. and it makes me think TXD will stay low if no data is transmitted. If that document is correct, then if I choose to switch devices then the last device used will have a low to high transition (meaning an extra unwanted bit is to be processed).
My only other options are to explore other serial modes and if that wont work, I may have to bit bang or redo the entire hardware (which is an option I will not take).
Anyone have any solid solution to this?