[Icc-avr] Interrupt Help Please (Happy New Year)

Andrew andrew_166 at msn.com
Thu Jan 3 08:34:21 PST 2008


Hi john,

I am actually powering the RTC from a port as it only takes 100uA ( not my 
desgin, more a temparay fix).

The thing is the code works with out change alsong as i dont't plug in the 
USB. So i can make it sleep and resume from sleep all day long by swaping 
the power over from backup battery to power (so PORTD BIT 1 goes high and 
low). but if i plug in the USB connector and disconnect the USB connecor to 
make the processor sleep. the sleep current goes p to 112 - 120uA.

Can you see something in the USB that i am not turnning off, it seems to me 
that the USB or some part of it is staying on.

Andy



----- Original Message ----- 
From: "John Baraclough" <j_baraclough at zetnet.co.uk>
To: "Discussion list for ICCAVR and ICCtiny Users. You do NOT need 
tosubscribe to icc-announce if you are a member of this." 
<icc-avr at imagecraft.com>
Sent: Thursday, January 03, 2008 3:37 PM
Subject: Re: [Icc-avr] Interrupt Help Please (Happy New Year)


> The processor is clearly in a different state when it goes to sleep from 
> when it first starts up. At a guess, I would say you are leaving a port 
> pin enabled and driving a low level out to a pull-up resistor (possibly 
> more than one). Calculating the extra current; 112uA would be the current 
> drawn through a 47k resistor from a 5V supply (or 30k and 3.3V).
>
> What is the mechanism for turning off the RTC? The ideal way to do this is 
> to use a resistive pull-up/pull-down to turn off the RTC and then 
> overdrive it with the appropriate level from a port pin to turn it on. 
> When the processor goes to sleep just tri-state all the port pins so there 
> is no current drawn.
>
> HTH
>
> John
>
> Andrew wrote:
>> Hi john/anybody ,
>>  I have a intresting/anoying problem. to recap. I have an AT90USB162. i 
>> am basically trying to send the processor to sleep if Bit 1 on PORTD is 
>> high and wake when the PIN goes low. The basically tells the processor it 
>> has lost main power and is now running on a battery.
>>  I have the code working well and i am getting 7.12uA when the Processor 
>> is asleep.and my pin interrupt routine works and wakes the processor if 
>> PORTD BIT1 is low and returns back to the 7.12uA when PORTD BIT1 is high. 
>> The problem i have is when i pug the USB in. This also has the same 
>> effect on PORTD BIT 1 as it now takes over powring the system from the 
>> battery.
>>  So as before if the USB connector is pugged in PORDT BIT 1 goes low and 
>> the processor resumes from sleep. this also works and i can use the USB 
>> port as a serial emulator using some atmel exmaple code. The probelm 
>> comes when i unplug the USB connector. Which sends PORTD BIT 1 high and 
>> thus the processor goes to sleep but it only goes down to 119uA not the 
>> 7.12uA i was getting before. I have checked and the processor is asleep 
>> as the external oscillator is turnned off. So some part of the USB must 
>> be still enabled. Can anybody suggest a solution: -
>>  CODE
>>  NOTE : -
>>
>> #define USB_CONNECTED (PIND & 0x01)
>> #define BAT_CONNECTED (PIND & 0x02)
>>
>> are defined in a sepearte c file.
>>
>>  * *
>>
>> *void* sleep(*void*);
>> *void* wake(*void*);
>>
>> //-----------------------------------------------------------------------------
>> //
>> // Function name : Sleep
>> //
>> // Returns : None
>> //
>> // Parameters : None
>> //
>> // Purpose : Send the processor into sleep mode (Low power)
>> //
>> //-----------------------------------------------------------------------------
>> *void* sleep(*void*)
>> {
>>
>> SPCR = 0x00;                    // Power Down the SPI
>> UCSRB = 0x00;                // NOT FOUND THIS IN THe DATASHEET
>>
>> REGCR = 0x01;                 // Disable the USB Regulator
>> RTC_POWER_OFF          // Turn the Power too the RTC OFF (PORTD4)
>>
>> EICRA = 0x08;                // Change INT1 Pin Interrupt to Falling Edge 
>> (INT1)
>>
>> PRR1 = 0x81;                    // Turn Off the USB and USART using the 
>> power reduction register
>>
>> SMCR = 0;                         // Clear SMCR Register
>> SMCR = 0x05;                   // Configure Sleep Register for Deep Sleep
>> asm(/"sleep"/);                     // Put Processor into Deep Sleep
>>
>> }
>>
>> //-----------------------------------------------------------------------------
>> //
>> // Function name : Wake
>> //
>> // Returns :
>> //
>> // Parameters :
>> //
>> // Purpose : Return from Sleep mode and restart devices
>> //
>> //-----------------------------------------------------------------------------
>> *void* wake (*void*)
>> {
>> PRR1 = 0x00;                 // Restart the USB from Power Reduction Mode
>> EICRA = 0x0C;              // Change the Battery on pin to interrupt on 
>> rising edge (INT1)
>> RTC_POWER_ON        // Turn the RTC Power Supply back on (PORTD4)
>>
>> UCSRB = 0x98;               // HAVE NO IDEA WHAT THIS REGISTRY IS FOR
>> SPCR = 0x5C;                 // Restart the SPI
>> Usb_enable_regulator();    // Enable the USB regulator
>> }
>>
>> //-----------------------------------------------------------------------------
>> // Main Program Loop
>> //-----------------------------------------------------------------------------
>> *void* main(*void*)
>> {
>> init_devices();                 // Initilise all the devices
>>
>> Usb_enable_regulator(); // Enable the USB Regulator
>> usb_scheduler_init();       // Set up the USB Scheduler
>>
>> *while* (1)
>> {
>>
>> *if*(USB_CONNECTED) // If the USB Connected Pin is High
>> {
>> usb_scheduler_tasks();    // Schedule the USB tasks
>> }
>>
>> *if*(BAT_CONNECTED)  // If the Battery Connected Pin is high
>> {
>> sleep(); // Call the Sleep function
>> NOP(); // Small Delay
>> NOP(); // Small Delay
>> wake(); // Wake from Sleep and restart USB and SPI
>>
>> }
>>
>> }
>> }
>>
>>  Andy
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Icc-avr mailing list
>> Icc-avr at imagecraft.com
>> http://dragonsgate.net/mailman/listinfo/icc-avr
>>
>
> _______________________________________________
> Icc-avr mailing list
> Icc-avr at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-avr
> 



More information about the Icc-avr mailing list