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

Johannes Assenbaum jassenbaum at htp-tel.de
Thu Jan 3 14:36:07 PST 2008


Would be nice, if you can tell how :-)

Johannes

> Hi,

> i have fixed it :) it now sleeps at 6uA in both conditions :)

> Andy

> ----- Original Message -----
> From: "Albert vanVeen" <Albert.vanVeen at pertronic.co.nz>
> To: "Johannes Assenbaum" <jassenbaum at htp-tel.de>; "Discussion list for
> ICCAVR and ICCtiny Users. You do NOT needtosubscribeto icc-announce if you
> are a member of this." <icc-avr at imagecraft.com>
> Sent: Thursday, January 03, 2008 8:04 PM
> Subject: RE: [Icc-avr] Interrupt Help Please (Happy New Year)


>> Yes, you're right: writing/reading emails must take as must time as just
>> reading the datasheet.
>> "Being new" is no excuse for not reading it, it is the ultimate reason.
>> When I took over my first AVR project from a colleague 2 years ago, I
>> spent most of the first day reading the datasheet to see what the
>> characteristics and possibilities are. This is not a waste of time, but
>> a good investment!
>>
>> And: happy new year everyone.
>>
>> Albert.
>>
>>
>>
>> -----Original Message-----
>> From: icc-avr-bounces at imagecraft.com
>> [mailto:icc-avr-bounces at imagecraft.com] On Behalf Of Johannes Assenbaum
>> Sent: Friday, January 04, 2008 07:10 AM
>> To: icc-avr at imagecraft.com
>> Subject: Re: [Icc-avr] Interrupt Help Please (Happy New Year)
>>
>> Setting a bit in DDR enables corresponding port pin for output.
>>
>> So correct io setup for all-inputs i.e. all hi-Z-state is DDRx = 0;
>>
>> How about reading the datasheet?
>>
>> Best regards,
>> Johannes
>>
>>
>>> Hi
>>
>>> How does one tri-state all the inputs?
>>
>>> is this correct?
>>
>>>  PORTD = 0x00;
>>>  DDRD  = 0xFF;
>>
>>> 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
>>>>
>>
>>> _______________________________________________
>>> 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/1207 - Release Date:
>>> 02.01.08 11:29
>>
>>
>> _______________________________________________
>> Icc-avr mailing list
>> Icc-avr at imagecraft.com
>> http://dragonsgate.net/mailman/listinfo/icc-avr
>>
>> Scanned by Bizo Email Filter
>>
>>
>> _______________________________________________
>> 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


> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.17.13/1207 - Release Date: 02.01.08 11:29




More information about the Icc-avr mailing list