Tricky Timing Issue - Polling vs ISR/Interrupt


i'm using attiny85 provide millisecond interrupt clock z80 micro.  clock pulse drives z80's /int pulse triggering service routine issues output instruction clear interrupt. z80 takes 30 respond interrupt , pulse issues .5 us. need de-assert clock pulse inside of 1 or so. (https://olduino.wordpress.com/2015/10/26/not-much-luck-with-the-timer/)

the logic i'm using in attiny looks following. khz, nkhz, , ntclr pins on portb.
code: [select]

while(1){ //loop
portb=((1<<nkhz);//assert clock
while(pinb & (1<<ntclr)); //wait z80 clear **risk getting stuck here**
portb=(1<<khz);//de-assert clock
_delay_us(1000); // 1khz cycle
}

my main worry if missed z80's pulse in third line never recover.  there's loose timing that's not important.

one alternative use millisecond timer interrupt start pulse , pin change or  external interrupt interrupt clear it. alternatively put timeout counter on spin if didn't risk missing pulse.

oh, brute force make pulse short - 20-25 us. z80 might miss interrupts once in while doesn't matter much.  sounds plan.

thoughts?

bill rowe
olduino - arduino first of us
www.olduino.wordpress.com
https://sites.google.com/site/lcc1802/

quote
my main worry if missed z80's pulse in third line never recover. 
how possibly miss it? code doing nothing staring @ pin, waiting go high.


Arduino Forum > Using Arduino > Project Guidance > Tricky Timing Issue - Polling vs ISR/Interrupt


arduino

Comments