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

Timer 1 as interrupt
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SET



Joined: 15 Nov 2005
Posts: 161
Location: Glasgow, UK

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

PostPosted: Thu Aug 30, 2007 4:47 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 30, 2007 5:28 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 30, 2007 5:43 am     Reply with quote

Thanks for code.

It seems to work, just one quick question:-
Is there a Interrupt service routine for the PERIPHERAL interrupt?

I have tried:-
Code:
#int_peripheral

but that does not work.

Thanks
Stephen
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Thu Aug 30, 2007 5:47 am     Reply with quote

Quote:

It seems to work,
Very Happy

Quote:

but that does not work.
Shocked

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

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

PostPosted: Thu Aug 30, 2007 6:07 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Aug 30, 2007 6:48 am     Reply with quote

Quote:
It seems to work

refers to the code snippet
Quote:
but that does not work.

refers to the bit directly above 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
Page 3 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