Problems reading time in milliseconds

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

cross mob
Johan_Ha
Level 1
Level 1
First like given 5 sign-ins First reply posted

I'm new to Infineon and PSoC. I need to read the time in milliseconds from power on. Or any time running in milliseconds. I'm experienced with Arduino, and there we use a simple millis() function, which handily returns the milliseconds from start up. I have the impression I have to build up a clock or a timer or some similar entity. But I can't find any examples how to do it.

0 Likes
1 Solution
Gautami_12
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @Johan_Ha,

cyhal_system_delay_ms(unit32_t milliseconds) is the API  that gives the delay in millisecond parameters. Please refer to HAL to understand the APIs used in the mtb-example-psoc6-wdt  code example. You can use this API in your project to create a millisecond delay.

The watchdog timer code example explains how to set up a Watchdog Timer (WDT) using the WDT HAL resource. The WDT resets the device if it is not serviced or "kicked" within the configured timeout interval. This helps in recovering the program from an unintended lockup.

The LPTIMER code example explains how to set up a low-power timer using the LPTimer HAL resource to measure the timing between events in free-running mode on the PSoC board.

You can even refer to the watchdog pdl code example  it has a code to create a millisecond delay  using PDL API's.you can keep this as a reference and design project that deals with milliseconds.

It's not necessary to use a low-power timer itself you can even use the normal timer. To know more about it please refer to TCPWM (Timer Counter PWM) in PDL documentation and Timer\counter in Hal documentation.

Warm Regards,
Gautami J

View solution in original post

0 Likes
4 Replies
Gautami_12
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi,

Can you please let me know the name of the development board and also if you are using PSoC™ Creator or ModusToolbox™ Software to implement your project.

Warm Regards,
Gautami J

0 Likes
Johan_Ha
Level 1
Level 1
First like given 5 sign-ins First reply posted

I'm using the PSoC 62S2 WiFi BT Pioneer Kit

CY8CKIT-062S2-43012

And Modus Toolbox.

 

0 Likes
Johan_Ha
Level 1
Level 1
First like given 5 sign-ins First reply posted

Ok, I think I found one timer that works. LPTIMER.

For a newbie it's a bit confusing. LP stands for low power. I just need any clock that ticks the milliseconds (or any other time code). I also found some "Watchdog" timer. Yet another confusing name. Right now I just read the ticks in the LPTIMER. Guess I need to read the frequency if I want to turn the ticks into milliseconds, but that's trivial.

 

0 Likes
Gautami_12
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @Johan_Ha,

cyhal_system_delay_ms(unit32_t milliseconds) is the API  that gives the delay in millisecond parameters. Please refer to HAL to understand the APIs used in the mtb-example-psoc6-wdt  code example. You can use this API in your project to create a millisecond delay.

The watchdog timer code example explains how to set up a Watchdog Timer (WDT) using the WDT HAL resource. The WDT resets the device if it is not serviced or "kicked" within the configured timeout interval. This helps in recovering the program from an unintended lockup.

The LPTIMER code example explains how to set up a low-power timer using the LPTimer HAL resource to measure the timing between events in free-running mode on the PSoC board.

You can even refer to the watchdog pdl code example  it has a code to create a millisecond delay  using PDL API's.you can keep this as a reference and design project that deals with milliseconds.

It's not necessary to use a low-power timer itself you can even use the normal timer. To know more about it please refer to TCPWM (Timer Counter PWM) in PDL documentation and Timer\counter in Hal documentation.

Warm Regards,
Gautami J

0 Likes