View previous topic :: View next topic |
Author |
Message |
Newbee Guest
|
newbee - wakeup from sleep |
Posted: Sun Jun 19, 2005 12:42 pm |
|
|
I want to wakeup from sleep on button press BUT the switch is not connected on any INT pin... How to make wakeup on button press when the pin ( where the switch is connected ) has no interrupt (ex. b3) ... Any example would be good..
Thank you in advance |
|
|
Ttelmah Guest
|
|
Posted: Sun Jun 19, 2005 2:58 pm |
|
|
If there is no interrupt, then it cannot be done.
However b3, on most chips, does support the 'interrupt on change' feature.
Best Wishes |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Sun Jun 19, 2005 7:22 pm |
|
|
A work around is to use a timer interrupt and periodically (say every 5ms) wake up, check the switches, if no change then go back to sleep. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Newbee Guest
|
|
Posted: Mon Jun 20, 2005 1:19 am |
|
|
Can "general purpose I/O" pin be used like interrupt on change pin for wakeup?. If so, then how to make this? |
|
|
valemike Guest
|
|
Posted: Mon Jun 20, 2005 7:40 am |
|
|
Newbee wrote: | Can "general purpose I/O" pin be used like interrupt on change pin for wakeup?. If so, then how to make this? |
Code: |
If there is no interrupt, then it cannot be done.
However b3, on most chips, does support the 'interrupt on change' feature.
|
Ttelmah answered that question. Don't make life too hard on yourself, and just use an interrupt pin. That's what they're there for. Yes, you can wake up every few ms to check the pin, but why sleep then?
-Mike |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jun 20, 2005 8:52 am |
|
|
The typical PIC has the Interrupt-on-Change feature on pins RB4-RB7.
It's possible that some PICs may have it on RB3, but I just checked
about 15 data sheets of PICs commonly discussed on this forum and
they all only support it on RB4-RB7. |
|
|
Newbee Guest
|
|
Posted: Mon Jun 20, 2005 10:30 am |
|
|
I didn't make electronic :-))
Beside, this can always happen ( switch on some general purpose pin ).
I must use sleep and for now i am stuck in sleep, waiting to wake up on switch press.
I can not change switch pin connections.
Asmallri says: you can use wdt to check the state of the pin. Ok, but then i must wakeup each, what 5 ms. Is there any use of sleep then.. |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
|
valemike Guest
|
|
Posted: Mon Jun 20, 2005 12:07 pm |
|
|
Newbee wrote: | I didn't make electronic :-))
Beside, this can always happen ( switch on some general purpose pin ).
I must use sleep and for now i am stuck in sleep, waiting to wake up on switch press.
I can not change switch pin connections.
Asmallri says: you can use wdt to check the state of the pin. Ok, but then i must wakeup each, what 5 ms. Is there any use of sleep then.. |
You can set up the wdt to re-wake you up every ~2 seconds (set it to the max), but then you're response time to pushbutton presses would be sluggish, and you'd probably miss a quick keypress tap. |
|
|
Newbee Guest
|
|
Posted: Mon Jun 20, 2005 3:09 pm |
|
|
My electronic is set and i can make any changes.
I hope i have understand this correctly:
You sayed that there is a way to route a signal to desired pin ?
Do you meen something like this:
Some general purpose pin (ex. C3 )
If i click C_3 i can reroute this signal to some INT pin and make interrupt on change ? If this is programaticly possible, PLEASE show me how.
and
excuse me if i get you wrong... |
|
|
Ttelmah Guest
|
|
Posted: Mon Jun 20, 2005 3:19 pm |
|
|
Repeat after me.
There is no way to do this programmatically. If you need a fast wake up, then you need to solder a wire to a pin that does support the ability.
Others have posted solutions that can be made to work. For example, use the watchdog, at (nominally) 18mSec. every time you wake, simply check the one pin, and if it is not in the state you want, loop, and go to sleep again. The total 'awake' time, will only be perhaps 10 instruction cycles every 18mSec, and the power consumption will still be tiny.
Best Wishes |
|
|
Newbee Guest
|
|
Posted: Tue Jun 21, 2005 1:16 am |
|
|
OK. Let's go with WDT.
I saw some of the questions regarding WDT in this forum.
Some of them have example how to use wdt for such cases but i need your suggestion / link.
If i have to set the WDT to check the switch state ( and make wakeup ), how should i do that ? |
|
|
Ttelmah Guest
|
|
Posted: Tue Jun 21, 2005 2:17 am |
|
|
PCM programmer wrote: | The typical PIC has the Interrupt-on-Change feature on pins RB4-RB7.
It's possible that some PICs may have it on RB3, but I just checked
about 15 data sheets of PICs commonly discussed on this forum and
they all only support it on RB4-RB7. |
Several of the 'smaller' chips, where the 'GPIO' port, is mapped at the addresses for PortB, have interrupt-on-change, on the whole port. However I don't know of any 'larger' chips that do this.
Back to the original poster. To give any idea of how to do this, we need to know which chip is involved. Some of the small chips, implement the wake-up in a different way to the larger chips. Also, on the 'power consumption' front, there is a lot of difference according to the oscillator 'mode'. If (for instance), you are using a standard crystal, the chip has to power this up, and wait for it to stabilise before running. With an external oscillator, this delay (and extra consumption), does not happen, but then you have the power drawn by the oscillator running all the time. The 'lowest power' setup, is either an internal, or external RC oscillator, which powers up almost instantly.
Best Wishes |
|
|
Newbee Guest
|
|
Posted: Tue Jun 21, 2005 3:45 am |
|
|
Electronic is made for small (44 pins ) nanowatt technology chip.
I dont know which chip will be used but i definitive know that we will use internal oscilator on 4 mhz and i definitivly know that the switch is not on INT pin... (it will be on some general purpose pin)
So lets go with INTERNAL osc and WDT. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Jun 21, 2005 5:13 am |
|
|
You know all kind of details about the chip, including the number of pins but you can't give us a type number??? Is this because you haven't figured out the required memory size yet? At least give us the number of a chip that is pin compatible to what you are thinking of.
We want to help you, but we don't want to waste our time on giving suggestions that won't work on your processor. |
|
|
|