[Icc-avr] Interrupt Help Please (Happy New Year)
Andrew
andrew_166 at msn.com
Tue Jan 1 09:46:54 PST 2008
Hi,
Can somebody explain/show how i can get an interrupt on a pin change. I am using the AT90USB162 and the pin i need to monitor for change is on PORTD 1 which is INT1.
Basically i need to go to sleep if it goes from low to high. and wake if it goes from high to low. I think the code should be something like this :-
#pragma interrupt_handler XXXX_isr:XX
void Pin_State_Change(void)
{
CHECK THE STATE OF THE PIN
IF (PIN STATE HAS CHANGED)
{
MAKE PIN_FLAG = 0X02
}
void main()
{
if (pin_changed == 0x01)
{
SMCR = 5;
asm("sleep");
}
}
I could just using polling in my main code to check the Pin state has changed but then if i call: -
asm("sleep");
how do i get the AVR to wake up again and re-enable all the devices??
If somebody has an example of pin interrupts they can send that will help me understand them and the sleep function that would be much appriceated.
Many Thanks (Happy New Year ALL)
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20080101/56cd9838/attachment.html
More information about the Icc-avr
mailing list