[Icc-avr] Interrupt Help Please (Happy New Year)
Johannes Assenbaum
jassenbaum at htp-tel.de
Wed Jan 2 12:28:47 PST 2008
You still may need to enable interrupts by
SEI();
or
asm("sei");
before entering sleep mode.
Best regards,
Johannes
> You need to initialise the interrupts correctly so that they respond to
> the appropriate edges.
> I once solved a problem by putting a couple of NOPs after the sleep
> instruction and have always done it since. I still don't know why it
> worked but it's just routine now.
> asm("sleep");
> asm("nop");
> asm("nop");
> HTH
> John
> Andrew wrote:
>> Hi John,
>>
>> My main code is basically this: -
>> //-----------------------------------------------------------------------------
>>
>> // Sleep Function
>> //-----------------------------------------------------------------------------
>>
>>
>>
>> void sleep_mode(void)
>> {
>>
>> DF_Deep_Power_Down();
>> DF_Deep_Power_Down_2();
>>
>> SPCR = 0x00;
>> ACSR |= 0x80;
>>
>> UCSRB = 0x00;
>> PRR1 |= 0x08;
>> REGCR |= 0x01;
>>
>> PORTD = 0x00;
>>
>> //port_init_off();
>>
>> SMCR = 0;
>> SMCR = 5;
>> asm("sleep");
>> }
>>
>> //-----------------------------------------------------------------------------
>>
>> // Main Program Loop
>> //-----------------------------------------------------------------------------
>>
>> void main(void)
>> {
>>
>> init_devices();
>>
>> Usb_enable_regulator();
>> usb_scheduler_init();
>>
>> sleep_mode();
>>
>> while (1)
>> {
>>
>>
>> if(!TestBit(bFlags,TEST_MODE))
>> usb_scheduler_tasks();
>>
>> }
>> }
>>
>> //-----------------------------------------------------------------------------
>>
>> // INT0 - Interruopt Handler
>> //-----------------------------------------------------------------------------
>>
>> #pragma interrupt_handler int0_isr:iv_INT0
>> void int0_isr(void)
>> {
>> //external interupt on INT0
>> }
>>
>> What i need to do is if either INT0 or INT1 go from low to high i need
>> to wake the system from sleep and re-enable the USB and SPI, but i am
>> having problems.INT0 goes from low to high if a USB cable is pulgged
>> in and INT1 is high if the device switchs from a battery source to a
>> main power source. either of these need to resut in waking the system.
>> Then i put the system to sleep if INT1 is low and reset theinterrupts.
>> Andy help would be good.
>>
>> Thanks,
>>
>> Andy
> _______________________________________________
> Icc-avr mailing list
> Icc-avr at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-avr
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.17.13/1206 - Release Date: 01.01.08 12:09
More information about the Icc-avr
mailing list