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

generate Interrupt with Timer0

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








generate Interrupt with Timer0
PostPosted: Tue Nov 28, 2006 2:26 am     Reply with quote

Hi
I would generate an Interrupt with Timer0 every 0.5second.

Have every one an example on C-Code for this problem?

thx
Ttelmah
Guest







PostPosted: Tue Nov 28, 2006 5:03 am     Reply with quote

No generic answer.
It'll depend on your master clock frequency, and the PIC involved. Chances are that it is not possible. Timer0, in the 12/16 PICs, is only an 8bit timer, with a prescaler (assuming this is not already being used by the watchdog). As such available division rates from the master clock, are:
256
512....
in binary steps, up to
32768
The timer is fed from the incoming clock/4, so with a crystal frequency above (32768*4)/2, it is just not possible. Below this, it is still only possible from a 'binary multiple' clock. So it can be done from a master clock of 32768Hz, but not (accurately) from a clock of 20000Hz.
On the 18 PICs, this timer can be switched to 16bit mode, allowing higher frequencies to be used, but the same restriction of needing to be a 'binary' clock rate remains, for an accurate result.
Timer2, is the 'choice' for this type of timing, since it has the ability to have the division ratio of the timer itself programmed, getting away from the need for a binary master clock.
The alternative, is to feed Timer0, from an external binary clock, running it at perhaps 32768Hz (the commonest 'watch' crystal), while the main CPU runs at a fater rate.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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