Free Running timer / counter availability in Fx3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
PrRe_3492461
Level 4
Level 4
First like received 50 sign-ins 50 replies posted

Hi there,

I'm using Fx3 for y product development,

My requirement is to track time at which certain interrupts occurred.

My plan is that If I have any free running timer so that I can start that timer and track the current time ticks when interrupt occurred that will serve my purpose.

or

If I have any counter so that I can track the count will also help me sort this out.

 

Also If free running timer is not available, I can also use normal timer and track current ticks count since timer start.

I found that I have "tx_timer_info_get" function in @tx_api.h, but not sure how to use this :

UINT tx_timer_info_get(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks, ULONG *reschedule_ticks, TX_TIMER **next_timer);

Can some one help me out with this.

Let me know If I have any of the possibility in Fx3 to achieve this requirement.

 

Thanks in advance!

Regards,

Pranay.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hi Pranay,

The function tx_timer_info_get can be used as it is in the application firmware. CyU3PTimerCreate, CyU3PTimerStart and CyU3PTimerStop API's are called to create, start and stop the OS Timer, respectively.

The procedure of implementation is

1. Parameters of CyU3PThreadCreate and tx_timer_info_get are declared at the start of the code. These parameters are listed below:     

CyU3PTimer TestTimer;
uint16_t TestActive;
uint32_t TestRemainingTicks;
uint32_t TestRescheduleTicks;
char name;
char *nameAddr = &name;

2. CyU3PTimerCreate API is called in ApplnInit function to create a timer.

3. CyU3PTimerStart is called wherever timer has to be started.                                                                     

4. tx_timer_info_get function is called to read the elapsed OS ticks, 'remaining ticks' parameter gives the time elapsed once the timer has started.                                                                                           

5.  CyU3PTimerStop and CyU3PTimerStart are called whenever timer has to be stopped and then resumed afterwards.

An example project with this implementation is attached for your reference.

Complex GPIO's on FX3 can also be used as timers to track delay between events as mentioned in the previous response

Best Regards,                                                                                                                                                   

AliAsgar

 

View solution in original post

0 Likes
6 Replies
AliAsgar
Moderator
Moderator
Moderator
1000 replies posted 250 solutions authored 750 replies posted

Hi Pranay,

If the time between the occurrence of two interrupts is  >1ms, then CyU3PGetTime() API can be used. For more information on this, you can refer to page no. 371 in FX3 API Guide and also this KBA .

If the time between the occurrence of two interrupts is <1ms, then complex GPIO timer can be used. Refer to this KBA for the implementation and there is this thread which contains example project, which might be helpful.

Best Regards,

AliAsgar

0 Likes

Hi AliAsgar,

By saying interrupts I mean that I have provision to send I2c commands whenever required so when certain operation happens I want to track its timestamp.

This "CyU3PGetTime()" is used to Get the number of elapsed OS timer ticks since FX3 system start-up, and the problem is this that if we set again use CyU3PSetTime(0) to reset time to zero - this will reset all the running timers which is a issue.

 

I want to re-iteratemy requirement , I want a counter to start, read present count and stop / restart whenever required.

Instead of counter a timer can also be used which can be started, track current ticks and can be stopped based on requirement.

 

Let me know how can I achieve this.

As I said earlier, with the help of threadx user manual I created a wrapper function for

UINT tx_timer_info_get(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks,
ULONG *reschedule_ticks, TX_TIMER **next_timer);

in @cyu3os.h file and defined pointer in @cyu3tx.h file. Does this work or do I need to make any further changes elsewhere to add/use existing functionalities from ThreadX ?

 

-- Pranay.

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Pranay,

The function tx_timer_info_get can be used as it is in the application firmware. CyU3PTimerCreate, CyU3PTimerStart and CyU3PTimerStop API's are called to create, start and stop the OS Timer, respectively.

The procedure of implementation is

1. Parameters of CyU3PThreadCreate and tx_timer_info_get are declared at the start of the code. These parameters are listed below:     

CyU3PTimer TestTimer;
uint16_t TestActive;
uint32_t TestRemainingTicks;
uint32_t TestRescheduleTicks;
char name;
char *nameAddr = &name;

2. CyU3PTimerCreate API is called in ApplnInit function to create a timer.

3. CyU3PTimerStart is called wherever timer has to be started.                                                                     

4. tx_timer_info_get function is called to read the elapsed OS ticks, 'remaining ticks' parameter gives the time elapsed once the timer has started.                                                                                           

5.  CyU3PTimerStop and CyU3PTimerStart are called whenever timer has to be stopped and then resumed afterwards.

An example project with this implementation is attached for your reference.

Complex GPIO's on FX3 can also be used as timers to track delay between events as mentioned in the previous response

Best Regards,                                                                                                                                                   

AliAsgar

 

0 Likes

I get it, I already have 4 timers created and are up and running.

Now I'm able to track current ticks as well. But seems like max time I can start a timer is only 1 min and there is no free running timer as per requirement.

let me know if any counter / free running timer apart from system timer (that reset all the timers if we set to 0).

--pranay.

0 Likes

Hi Pranay,

If an expiration function is used, where a flag can be incremented, number of minutes passed can be taken note of, for each timer.                                                                                                                  The timer may then be reloaded back to its previous loaded value.

In the last line of your post, are you mentioning about the Timer related to the GetTime() function, if not, could you please elaborate.

Best Regards,                                                                                                                                                                   AliAsgar

0 Likes

Hi Ali,

I'm able to achieve this requirement using "tx_timer_info_get ".

Thanks for the support.

I consider this topic as closed.

 

Regards,

Pranay.

0 Likes