View previous topic :: View next topic |
Author |
Message |
MJ
Joined: 25 Aug 2024 Posts: 2
|
Get ticks |
Posted: Wed Oct 16, 2024 4:44 pm |
|
|
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
|
|
Posted: Thu Oct 17, 2024 2:12 am |
|
|
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
|
|
Posted: Thu Oct 17, 2024 7:48 am |
|
|
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
|
|
Posted: Thu Oct 17, 2024 10:48 am |
|
|
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. |
|
|
|