Author Topic: Delay a signal by a clock, or 2, or 3  (Read 815 times)

0 Members and 1 Guest are viewing this topic.

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2196
Delay a signal by a clock, or 2, or 3
« on: February 12, 2018, 01:56:42 pm »
I am thinking of messing around with connecting a Z80 to an AVR and using the AVR for the I/O.  A few people have done this using a 7474 flop flop to trigger the WAIT signal on the Z80 so the AVR can keep up.  On an OUT instruction from the Z80 this should be simple, AVR captures data pins and clears the flip flop to allow the Z80 to continue, but an IN instruction requires the AVR to put data on the bus, release the WAIT, but then it also has to get off the bus before someone else needs to use it.

This assumes that the Z80 and AVR and clocked synchronously...

Pseudocode for it might be:

isr_for_IN_to_Z80()
{
PORTx=data;
DDRx=0xff;
set_pin_to_clear_flipflop
DDRxX=0x00;
clear_pin_to_clear_flip_flop
}

So my question is, if the time between set_pin_to_clear_flipflop and the next instruction to set the port to input is too long (and I don't know if it is or isn't), what type of logic device would you use to delay the set_pin_to_clear_flop?  Something that could delay by 1, 2, 3, clocks, etc.
 

Offline JVR

  • Regular Contributor
  • *
  • Posts: 201
  • Country: be
Re: Delay a signal by a clock, or 2, or 3
« Reply #1 on: February 12, 2018, 04:20:31 pm »
Simplest would be a decade counter, or a chain of flipflops.
 

Offline GeorgeOfTheJungle

  • Super Contributor
  • ***
  • !
  • Posts: 2699
  • Country: tr
Re: Delay a signal by a clock, or 2, or 3
« Reply #2 on: February 12, 2018, 05:38:59 pm »
A serial in parallel out shift register, feed the signal into serial in, connect the clock, and tap it delayed at the parallel out pins, bit #n -> n clocks delayed.
The further a society drifts from truth, the more it will hate those who speak it.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf