View previous topic :: View next topic |
Author |
Message |
quicksilver
Joined: 04 Feb 2009 Posts: 31
|
|
Posted: Wed Mar 21, 2012 2:49 pm |
|
|
Just to clear this out a little bit, I wanna send the pic to sleep, and wake it up with an external interruption, in this case, the crystal that I'm using. _________________ everything that has a beginning, has an end |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Mar 21, 2012 3:06 pm |
|
|
sleep can be tricky to program
and tricky to cleanly exit as well -
the data sheet for the part
check out 3.4 and 3.7 in particular |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 21, 2012 3:16 pm |
|
|
Quote: | wake it up with an external interruption, in this case, the crystal that I'm using. |
How do you propose to do that ? The crystal oscillator circuit in the PIC
is shut down during Sleep mode, to save power. The crystal won't be
oscillating and there will be no signal.
I assume you connected one side of the crystal to your External Input
pin on the PIC, in addition to the crystal being connected to the normal
oscillator pins ?
That's not worth doing. The crystal doesn't put out an output voltage
high enough to trigger the interrupt. And as I said, the crystal doesn't
run during Sleep mode. Finally, even if it did run, and did have a high
enough voltage, the PIC would only be asleep for one crystal cycle, plus
the wake-up time. You need to think of a better experiment than this one. |
|
|
quicksilver
Joined: 04 Feb 2009 Posts: 31
|
|
Posted: Wed Mar 21, 2012 3:39 pm |
|
|
OK, I don't get it. I've seen post with this problem too, actually, PCM Programmer participated in one of them related with this same problem.
Here is the link http://www.ccsinfo.com/forum/viewtopic.php?t=28158&start=8.
So, it should be possible to send the pic to sleep and after a time wake it up from sleep. Any clue about it.[/url] _________________ everything that has a beginning, has an end |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 21, 2012 3:45 pm |
|
|
Right, but that thread is about using a 2nd crystal (a 32.768 KHz watch
crystal) on the Timer1 oscillator pins. Those are totally different pins than
the main PIC oscillator pins. Also, that program is waking up the PIC
when it gets a Timer1 interrupt. It's not from an external interrupt.
Timer1 runs with the watch crystal, even though the PIC is in sleep mode.
What do you really want to do ? |
|
|
quicksilver
Joined: 04 Feb 2009 Posts: 31
|
|
Posted: Wed Mar 21, 2012 3:54 pm |
|
|
I wanna wake up the PIC from sleep, that's all, can you help me please??? I've seen the datasheet, and are the same pins for the PIC 16F688. So, do I need a second crystal??? _________________ everything that has a beginning, has an end |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 21, 2012 4:08 pm |
|
|
Do you want to do this as an experiment, just to prove that you can
wake up the PIC from sleep by any method ? Or do you need a
specific method ?
Do you have a PIC development board ? If so, which one ?
Or did you build a board yourself, or are you testing this on a 3M
breadboard ? Or is this a Proteus project ?
I want to know what hardware you have available. |
|
|
quicksilver
Joined: 04 Feb 2009 Posts: 31
|
|
Posted: Wed Mar 21, 2012 4:14 pm |
|
|
Let's start with this... I have a pic 16F688 with a 4MHz Xtal connected with 22pF capacitors. I have a LED that shows me that the pic woke up.
Couple of things, I have read the datasheet of this PIC, and I'd like to point out a couple of problems.
Quote: | Timer1 can only operate during Sleep when setup in
Asynchronous Counter mode. In this mode, an external
crystal or clock source can be used to increment the
counter. To set up the timer to wake the device:
• Timer1 must be on (T1CON<0>)
• TMR1IE bit (PIE1<0>) must be set
• PEIE bit (INTCON<6>) must be set
The device will wake-up on an overflow. If the GIE bit
(INTCON<7>) is set, the device will wake-up and jump
to the Interrupt Service Routine (0004h) on an overflow.
If the GIE bit is clear, execution will continue with the
next instruction. |
I read this on the datasheet (page 52), I tried to set up the timer1 in Asynchronous Counter mode, but I couldn't. So, any help??? Any suggestion??? _________________ everything that has a beginning, has an end |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Wed Mar 21, 2012 4:23 pm |
|
|
The key point is the words _external crystal or clock source_. You _cannot_ wake from sleep using the master oscillator, because this is stopped when you are asleep.
You _must_ have either an external oscillator that runs while the PIC is asleep, or a low power crystal on the timer1 pins. The thread you have already found, shows you how to program this, but the hardware is also needed.
Best Wishes |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Wed Mar 21, 2012 4:51 pm |
|
|
data sheet section 4.2 3 and 4.2 4
also offer an elegant and simple way to exit sleep -
but do not use a crystal in any way. |
|
|
quicksilver
Joined: 04 Feb 2009 Posts: 31
|
|
Posted: Tue Mar 27, 2012 8:59 am |
|
|
So, guys, wait a second. So, I'm using 4MHz crystal, those that have two pins. I'm not using an oscillator. Is it possible to run it with a Crystal??? _________________ everything that has a beginning, has an end |
|
|
quicksilver
Joined: 04 Feb 2009 Posts: 31
|
|
Posted: Mon Apr 09, 2012 3:46 pm |
|
|
So, is this true??? This was taken from the datasheet... page 52.
Quote: | If an external clock oscillator is needed (and the
microcontroller is using the INTOSC without CLKOUT),
Timer1 can use the LP oscillator as a clock source. |
Can I use a crystal to generate my interruption???. _________________ everything that has a beginning, has an end |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Apr 09, 2012 4:05 pm |
|
|
Quote: |
Timer1 can use the LP oscillator as a clock source.
|
see section 6.4 and 11.6.1 of the data sheet
you can use a low power watch crystal with the lowest frequency possible and use the MAX timer1 prescalar to get a timed wake from sleep.
32 to 38 khz are common but freqs as low as 10khz are possible
here is a Mouser vishay dale part that would do it
XO56BR10KHZ
50 pf phase caps
this one will let you sleep for 52.5 seconds before timer1 overflows
sleep commence |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Apr 09, 2012 5:28 pm |
|
|
i mentioned 10 khz because there are such beasties -
tho i admit - i did not pick one
however they are out there
see CC1V-T1A
for instance from Micro Crystal Switzerland
10 khz will give a longer sleep time and that is the reason i mentioned it |
|
|
|