Hi. I'm fairly new to Arduino so go easy on me and certainly not an expert on electronics!
My project requires that a set of 8 pins output two very different sets of data quickly based on the hi or lo state of another select pin. I have everything almost working unfortunately the time between going lo and reading values is too quick to update the pins with the correct data. The values are all pre-calculated so it is literally just a case of updating the 8 output pins (all connected to a single port - PORTE) with a byte value. I have tried using a tight loop directly reading the select pin using direct port IO and also tried using an interrupt on a falling edge and a single write to PORTE inside the interrupt unfortunately it is still too slow. Looking at the source device it's a 68000 running at 8Mhz and it does a single NOP after setting the select line low before reading values so I guess I have cope with just a 2 clocks interval to switch the value.
Is there any way the hardware on the device (a MEGA 2560) can switch this if I put the other 8 values on another separate 8 pins? If not is there a simple IC that can switch between 2 different sets of 8 pins based on a single pin change quickly (5volts on all pins)? I looked at MUX's/DEMUX's but they are not quite what I want I don't think? I think I really want a 2throw8pole IC (I think that's right way around?) Any advice would be greatly appreciated.
It's hard to advise what the problem could be, or solutions, without seeing your code and schematic, but it could be that a 16MHz CPU is not fast enough to react to the output of an 8MHz CPU I guess.
Maybe a hardware solution could work?
Perhaps 2x 74hc595 and an inverter gate (74hc04)? You could load the desired outputs into each register, then have your input signal enable the output of one or the other register.
Slightly clinging on by my fingernails to understanding your reply... So you would connect the inverter to the output enable on one of those shift registers and then connect the select line to that inverter as well as directly to the other shift registers output enable and then just connect all 8 output lines together and it would output values from one or the other based on the select line?
Another option could be 2x 74lsHC241 octal buffers. Use two ports on the Mega to output the desired data, and use the chips to make the '2throw8pole' switch you described.
With 74lsHC241, there are 2 output enable pins, one active low and the other active high, so you would not need the 74hc04 inverter.