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

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

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

ソリューションへジャンプ
2,566件の閲覧回数
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?

ラベル(1)
タグ(4)
0 件の賞賛
返信
1 解決策
2,552件の閲覧回数
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 件の賞賛
返信
2 返答(返信)
2,530件の閲覧回数
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.

2,553件の閲覧回数
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 件の賞賛
返信