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

External Clock PIC16F688
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
quicksilver



Joined: 04 Feb 2009
Posts: 31

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 2:49 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Wed Mar 21, 2012 3:06 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 21, 2012 3:16 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 3:39 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 21, 2012 3:45 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 3:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 21, 2012 4:08 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Wed Mar 21, 2012 4:14 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Mar 21, 2012 4:23 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Wed Mar 21, 2012 4:51 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Tue Mar 27, 2012 8:59 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Mon Apr 09, 2012 3:46 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Mon Apr 09, 2012 4:05 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Apr 09, 2012 4:59 pm     Reply with quote

Quote:
XO56BR10KHZ
50 pf phase caps

There are several problems with that part. This is the the actual part
number: XO56BR 10KHZ

1. It's "non-stocked" at http://www.mouser.com
2. It's way too expensive.
3. It's a DIP-14 package.
4. It's an oscillator, not a crystal.
5. It's 10 KHz, which is an un-common frequency.

You could use p/n X801, a 32.768 KHz watch crystal at http://www.digikey.com
http://search.digikey.com/us/en/products/ECS-3X8/X801-ND/17116
or for a Rohs compliant part:
http://search.digikey.com/us/en/products/ECS-3X8X/X1123-ND/827614

It's the crystal used on the Microchip PicDem2-Plus board.
They use two 22pf capacitors with it. It's crystal Y3 in the schematic
on page 35 of the PicDem2-Plus User's Guide:
http://ww1.microchip.com/downloads/en/DeviceDoc/41584B.pdf

I used that board, with that crystal circuit, to test the sample program
that you posted a link to, earlier in this thread.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Apr 09, 2012 5:28 pm     Reply with quote

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
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 Previous  1, 2, 3  Next
Page 2 of 3

 
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