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

Get ticks

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



Joined: 25 Aug 2024
Posts: 2

View user's profile Send private message

Get ticks
PostPosted: Wed Oct 16, 2024 4:44 pm     Reply with quote

Hi chaps, I'm new to CCS and am getting congrats with the built in functions.

How does the get-ticks() and set_ticks() functions work and how is it related to the timer ticks and the size of the bits in te timer setup. Does it process overflows etc or does it simply return the relevant timer value. I've looked at the manual but am a little confused.
Ttelmah



Joined: 11 Mar 2010
Posts: 19495

View user's profile Send private message

PostPosted: Thu Oct 17, 2024 2:12 am     Reply with quote

It returns a timer count, based on the size of timer counter you have specified
in the #USE TIMER setup. This is explained in the #USE TIMER manual entry.
It is a 'ticker', based on a hardware timer, rather than the timer itself.
The default if you don't specify a BITS= value in the #USE, is a 32bit value.
MJ



Joined: 25 Aug 2024
Posts: 2

View user's profile Send private message

PostPosted: Thu Oct 17, 2024 7:48 am     Reply with quote

Thanks, the manual still doesn't clearly explain how the function works. I tested it with the ICD and understand how it functions now.
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Thu Oct 17, 2024 10:48 am     Reply with quote

MJ wrote:
Thanks, the manual still doesn't clearly explain how the function works. I tested it with the ICD and understand how it functions now.


I would definitely suggest you give that feedback to CCS via their support email ( [email protected]) so they can improve the docs. However, I would recommend you be more specific. The phrase "doesn't clearly explain how the function works" is really unclear and in-specific. Like what part wasn't clear specifically?

On my end it seemed clear. Here was my train of thought. The manual entry for get_ticks() says:
Quote:

Returns the current tick value of the tick timer. The size returned depends on the size of the tick timer

That seemed pretty straight forward to me. It returns the current tick value of the tick timer and the size is based on the size of the timer.

It then provides a link to the tick timer section (#USE TIMER) which says
Quote:

This directive creates a tick timer using one of the PIC's timers. The tick timer is initialized to zero at program start. This directive also creates the define TICKS_PER_SECOND as a floating point number, which specifies that number of ticks that will occur in one second.


This explains how the tick timer is implemented (using a PIC timer), what it is initialized to and even provides some info on predefined related values.

I guess at this point, the only unknown is what a tick timer is, but that is a general embedded programming topic and not really CCS specific, so if that is the part that is unclear, then that just comes with experience working in embedded (regardless of the compiler).

Maybe you could highlight what parts weren't explained well? It helps with improving the documentation to have specific things to target.
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