| View previous topic :: View next topic |
| Author |
Message |
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Thu Aug 30, 2007 4:47 am |
|
|
For this device, connect your 32kHz crystal across Pins 2 and 3, and select Internal oscillator as your main clock source.
| Code: | #include <16F688.H>
#fuses INTRC,NOWDT, PROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C4, rcv=PIN_C5, ERRORS)
//===============================
void main()
{
setup_oscillator(OSC_4MHZ | OSC_INTRC);
printf("Start\n\r");
setup_timer_1(T1_CLK_OUT | 1);
clear_interrupt(INT_TIMER1);
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_PERIPHERAL);
sleep();
printf("Woke up from sleep\n\r");
while(1);
} |
|
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Aug 30, 2007 5:28 am |
|
|
Two comments:
1) enable_interrupts(INT_PERIPHERAL);
It is not a standard interrupt, it is not defined in any device.h file.
It had been included in the full code example posted by PCM_Programmer:
http://www.ccsinfo.com/forum/viewtopic.php?t=28158&start=8
2) It is a polite practice to mention the original author.
Humberto |
|
 |
sjharris
Joined: 11 May 2006 Posts: 78
|
|
Posted: Thu Aug 30, 2007 5:43 am |
|
|
Thanks for code.
It seems to work, just one quick question:-
Is there a Interrupt service routine for the PERIPHERAL interrupt?
I have tried:-
but that does not work.
Thanks
Stephen |
|
 |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Aug 30, 2007 5:47 am |
|
|
| Quote: |
but that does not work.
|
How do you know that it seem to work if you can“t compile it?
Humberto |
|
 |
SET
Joined: 15 Nov 2005 Posts: 161 Location: Glasgow, UK
|
|
Posted: Thu Aug 30, 2007 6:07 am |
|
|
| Quote: | Posted: Thu Aug 30, 2007 11:28 am Post subject:
--------------------------------------------------------------------------------
Two comments:
1) enable_interrupts(INT_PERIPHERAL);
It is not a standard interrupt, it is not defined in any device.h file.
It had been included in the full code example posted by PCM_Programmer:
http://www.ccsinfo.com/forum/viewtopic.php?t=28158&start=8
2) It is a polite practice to mention the original author. |
As I responded directly to the OP, I thought it was obvious that this was a modification to PCM_Programmer's code.
Basically I took the time to read the datasheet and modify as required. I deleted the #define INT_PERIPHERAL 0x0B40 as it was specific to the original code's target, of course I should have left it in!
In all honesty I didn't check out the INT_PERIPHERAL option, although It wasn't one I've used before.
Anyway, back to work.. |
|
 |
sjharris
Joined: 11 May 2006 Posts: 78
|
|
Posted: Thu Aug 30, 2007 6:48 am |
|
|
refers to the code snippet
| Quote: | | but that does not work. |
refers to the bit directly above it!!! |
|
 |
|