CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

newbee - wakeup from sleep
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Newbee
Guest







newbee - wakeup from sleep
PostPosted: Sun Jun 19, 2005 12:42 pm     Reply with quote

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







PostPosted: Sun Jun 19, 2005 2:58 pm     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Jun 19, 2005 7:22 pm     Reply with quote

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







PostPosted: Mon Jun 20, 2005 1:19 am     Reply with quote

Can "general purpose I/O" pin be used like interrupt on change pin for wakeup?. If so, then how to make this?
valemike
Guest







PostPosted: Mon Jun 20, 2005 7:40 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jun 20, 2005 8:52 am     Reply with quote

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







PostPosted: Mon Jun 20, 2005 10:30 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Mon Jun 20, 2005 10:47 am     Reply with quote

I use this on my keypads.
http://a330.g.akamai.net/7/330/2540/20050519160504/www.edn.com/contents/images/601828f1.pdf
notice how any activity on will trigger an IRQ. Can you do something like this?

If the hardware is desingned, then your stuck with what you have. Crying or Very sad
If the spec sheet for your PIC doesn't say its an INT then you won't wake up unless you route a signal to a pin that is.
valemike
Guest







PostPosted: Mon Jun 20, 2005 12:07 pm     Reply with quote

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







PostPosted: Mon Jun 20, 2005 3:09 pm     Reply with quote

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







PostPosted: Mon Jun 20, 2005 3:19 pm     Reply with quote

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







PostPosted: Tue Jun 21, 2005 1:16 am     Reply with quote

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







PostPosted: Tue Jun 21, 2005 2:17 am     Reply with quote

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







PostPosted: Tue Jun 21, 2005 3:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Jun 21, 2005 5:13 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group