I'm having a bit of a problem and hope someone can help me.
Basically I have one mega8 which sleeps and wakes up using an asynchronous clock. While awake this mega8 wakes another mega8 up by pulling the INT0 PIN from the other mega8 Low.
The first mega8 has to wait now for a reply from the other mega8 and then it has to pull that pin high again so that the second mega8 can go sleep again and then the first one goes to sleep and will awake from the clock to restart the whole procedure.
code from the first mega8:
the first mega8 waits now for the second mega8 to wake up and set the pin high.
code from the second mega8:
SetBit(DDRD, 2); //Set INT0 PIN as an Output
SetBit(PORTD, 2);//Pull INTO high
while no2 is on, it checks for a condition which it needs to send back to no1.
what i have done is if condition is checked then no2 sets the pin low and waits for no1 to acknowledge and then no1 will set it high again and no2 will go back to sleep
code for no2:
//send signal back to board no1...
ClrBit(PORTD, 2);//Pull INT0 PIN low
ClrBit(DDRD, 2); //Set INT0 as input
code for no1:
timer2 = 0;
detected = 1;
the problem i have is when no2 doesn't detect anything, sometimes both mega8's get stuck in a while loop and i have to reset the circuit board.
what would be the best method to let no1 wait a little while and when he knows that no2 isn't sending anything back he has to make sure that the pins are set and no2 can go to sleep and await its next instruction?
Thanks in advance
I apologize if some aspects aren't very clear, it's not really a simple problem that can be explained easily.