Best way to create a free running tick/time counter?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Best way to create a free running tick/time counter?

Jump to solution
1,454 Views
CanolCael
Contributor II

Hello, we have an LPC55S28 project where we would like to keep track of tick/time that has passed since the beginning of the program, to be able to check if certain actions are completed in time or compare their starting times etc. We can probably do it using timers and interrupts but we were wondering if there is a simple free running counter that continually counts upwards or downwards and overflows automatically once it reaches max value or zero.

In short we were wondering if there is a similar function for LPC55S28 of the millis() function of Arduino: https://www.arduino.cc/reference/en/language/functions/time/millis/

Is there such a function or if not, what is the best way to create such a function on LPC55S28?

Labels (1)
Tags (4)
0 Kudos
Reply
1 Solution
1,440 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @CanolCael,

I'm very sorry, but it appears there is no such example project for the 55s28. I suggest you refer to the _ctimer_match_interrupt_example, the CTimer generates a programmable period interrupt, in the ISR, you can switch the task to increment a variable and count how many seconds have passed in execution.

Another way to configure this would be to utilize Config Tools, as shown in this article: An example to configure a peripheral timer in an F... - NXP Community. You will need to apply it to the LPC, though.

Please feel free to ask me if you have any doubts with the Timer peripheral.

Best regards, Julian

View solution in original post

0 Kudos
Reply
2 Replies
1,418 Views
CanolCael
Contributor II

Thank you Julian, I ended up using the UTICK timer which was easier to set up than ctimers but the solution is, as you suggested, incrementing a counter variable during every interrupt.

1,441 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @CanolCael,

I'm very sorry, but it appears there is no such example project for the 55s28. I suggest you refer to the _ctimer_match_interrupt_example, the CTimer generates a programmable period interrupt, in the ISR, you can switch the task to increment a variable and count how many seconds have passed in execution.

Another way to configure this would be to utilize Config Tools, as shown in this article: An example to configure a peripheral timer in an F... - NXP Community. You will need to apply it to the LPC, though.

Please feel free to ask me if you have any doubts with the Timer peripheral.

Best regards, Julian

0 Kudos
Reply