Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
PolygonDVR
PostPosted: Jul 20, 2010 - 10:43 AM
Newbie


Joined: Jul 20, 2010
Posts: 1


Good day

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:
Code:

ClrBit(PORTD,6);
ClrBit(DDRD,6);
while(!(PIND&(BIT(6))));


the first mega8 waits now for the second mega8 to wake up and set the pin high.

code from the second mega8:
Code:

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:
Code:

if (condition_met)
{
    //send signal back to board no1...
          
    ClrBit(PORTD, 2);//Pull INT0 PIN low
    ClrBit(DDRD, 2); //Set INT0 as input
}//end if

while(!(PIND&(BIT(2))));


code for no1:
Code:

while (timer2)
{
    if (!(PIND&(BIT(6))))
    {
        timer2 = 0;
        detected = 1;
    }
}   
SetBit(DDRD,6);
SetBit(PORTD,6);
//if (detected)...


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.
 
 View user's profile Send private message  
Reply with quote Back to top
mquantz
PostPosted: Jul 22, 2010 - 10:41 AM
Hangaround


Joined: Jan 22, 2009
Posts: 180
Location: TX, NY

Quote:
what would be the best method to let no1 wait a little while and when he knows that no2 isn't sending anything back


An interrupt. Some interrupts can even wake a controller from sleep state.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits