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

Timer0 interrupt every 64 counts

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



Joined: 05 Aug 2017
Posts: 41
Location: brazil

View user's profile Send private message

Timer0 interrupt every 64 counts
PostPosted: Sun Oct 29, 2017 12:04 am     Reply with quote

I need to have a Timer0 interrupt every 64 counts or (with a clock of 4 MHz) every 64 Us.

Do I need to initialize the timer low every interrupt to a value of 255 - 64 = 191 ???
Is that the most practical way????

Thanks a lot
jujoab
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sun Oct 29, 2017 2:16 am     Reply with quote

You are going to have problems.

64uSec is only 64 instructions at your clock. It typically takes up to about 50 instructions just to get into and out of an interrupt.....
You need to be working with a faster processor to do anything practical at such a short interval.
It is always easier and better to use an interrupt that doesn't need you to set offsets like this. several instructions will have already been executed by the time you get into the handler routine.
If instead you went for 4* the CPU clock, then your timer will wrap with you having to do nothing, and you have some time left to actually do something in the routine....
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Oct 29, 2017 5:07 am     Reply with quote

Just a comment.

How accurate does the 64us need to be ?

If it needs to be 'bang on' and repeatable, then you'll need to use an external crystal and caps. The internal oscillator, while 'free' and OK for small NON time dependent projects isn't accurate enough for time specific projects. The 4 MHz is a 'nominal' value and does change based on temperature. Even between PICs you'll see a slight difference in speed.

Just something to be aware of.

Jay
jujoab



Joined: 05 Aug 2017
Posts: 41
Location: brazil

View user's profile Send private message

thanks to all
PostPosted: Mon Oct 30, 2017 2:21 pm     Reply with quote

Thanks to all for the valuable information.
I am trying another way, using PWM to generate the tick.

Thanks again
jujoba
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