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 and interrupt questions.

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



Joined: 18 Oct 2004
Posts: 21

View user's profile Send private message

Timer0 and interrupt questions.
PostPosted: Sat Apr 30, 2005 6:32 am     Reply with quote

I would like to ask if how to initialize and start timer0 in CCS C.

In 8051, after loading the Timers ans setting the interrupts, you can set TR register equal to 1 to start the timer running.

IN PIC, how to start timer running and what is the difference between set_timer0() and setup_timer_0().

Another if I already enabled interrupt and i have the loop f(;;) will the system run forever and interrupt when needed?

Thanks.
Ttelmah
Guest







PostPosted: Sat Apr 30, 2005 6:50 am     Reply with quote

The timer runs all the time if a clock is present.
Setup_timer_0, deterines where the clock is to come from, what prescaler is to be used etc..
Set_timer_0, puts the value into the counter register. It can be pretty useless in some cases, since at faster rates, the register will change by the very next instruction. Loading the counter registers, is something to only do with 'care'. Look for a lot of threads about this...

Best Wishes
glenjoy



Joined: 18 Oct 2004
Posts: 21

View user's profile Send private message

PostPosted: Sat Apr 30, 2005 7:03 am     Reply with quote

You have not answered my question, I am asking if how to get a timer running after loading it.
dyeatman



Joined: 06 Sep 2003
Posts: 1938
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Apr 30, 2005 7:16 am     Reply with quote

Ttelmah,
You try to help him and all he does is "smart mouth" you! I'd leave him to find his own answers.....
glenjoy



Joined: 18 Oct 2004
Posts: 21

View user's profile Send private message

PostPosted: Sat Apr 30, 2005 7:24 am     Reply with quote

Hey, what is your problem, I only told him that I am asking is the start of timer.

You are the big mouthed fool here.
Ttelmah
Guest







PostPosted: Sat Apr 30, 2005 7:28 am     Reply with quote

The timer is already running. There is nothing else to do. You can change the clock source, but the timer _keeps running all the time_. There is no secret instruction to start it, or magic involved.
Hence the comments about your reply.....

Best Wishes
glenjoy



Joined: 18 Oct 2004
Posts: 21

View user's profile Send private message

PostPosted: Sat Apr 30, 2005 7:55 am     Reply with quote

Hi,

I hope you get not offended my reply as someone interpreted it as offensive.

Now, how to stop the timer from counting?

Thanks.
Ttelmah
Guest







PostPosted: Sat Apr 30, 2005 8:22 am     Reply with quote

All you do is ignore the interrupt, if using this.
Understand, that Timer0, is a very basic counter indeed. Some of the other timers (assuming your chip has them), have more features, such as the ability to be used with the CCP, to give automatic resetting at particular counts, possibly interrupts after multiple rollovers (on ones that support a postscaler), and gate control. Potentially, if you are not using the T0CKI pin, and timer0 on your chip supports thus, you can switch timer0, to be clocked from this pin, and it will then stop (though make sure you have the pin pulled high/low, with an external resistor to avoid potential noise problems before doing this).
I suggest you pull the application note from the Microchip site, on using the timers. Basic 'rule' with CCS, is to look first at what your chip's hardware supports, and therefore the chip's data sheet, and then ask how to use the feature in CCS.

Best Wishes
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Apr 30, 2005 11:18 am     Reply with quote

Quote:
Now, how to stop the timer from counting?
By default all timers are running, stopping depends on the chip family you are using, as far as I know you can only disable the timers in the PIC18 series. For the PIC16 series instead of stopping the timer, why worry about this? Just let the timer continue and disable the resulting functions you don't like, for example disable the timer0 interrupt.

See the documentation for the setup_timer_0() function for more details, this will also point you to some example programs. Also read the header file for your processor in the PICC\devices directory, here you will see all allowed parameters for your processor.
bb



Joined: 06 Apr 2005
Posts: 7
Location: Germany

View user's profile Send private message

PostPosted: Sat Apr 30, 2005 12:59 pm     Reply with quote

Quote:
By default all timers are running, stopping depends on the chip family you are using, as far as I know you can only disable the timers in the PIC18 series.

No, only TMR0 is running. All other timers are disabled after a POR (PIC16 and PIC18 series).


Best regards,

Bernd
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