This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

comprehension question Timer

Hi,

maybe i have a silly question, but i didn't programm timers before. I know how they work. But how is it possible that there are only three Timers in the 51822 and so many parts of the programm part (PWM,BLE,GPIOTE...) which need a timer? How can i organize my timers?

and is it possible to run one timer and write a function like "get_actual_time" which gives me the time in the moment i call the function?

Best reagards, Nils :)

Parents
  • Hi Nils,

    as you say, there are 3 Timers available on the nRF51822. In addition there are 2 RTC's. The Timers use the 16 MHz clock (HFCLK) , while the RTC's use the 32 kHz clock (LFCLK).

    When the softdevice is enabled it reserves one Timer and one RTC (in addition to other HW resources). That leaves your application with 2 Timers and 1 RTC. For PWMs you would typically use a Timer, while timekeeping is usually done with an RTC.

    If you have multiple tasks that require millisecond-resolution timing, you can look into the SDK component app_timer. App_timer uses the RTC and facilitates timed events. For example: you want to read a sensor every 10 ms, do some processing every 100 ms, and then run a 3 second timeout for something.

    To summarize: the Timers are quite generic and can be connected to different peripherals to perform different functions.It's up to your application to make sure the Timers and RTCs are allocated (and multiplexed if needed) to the different tasks you want to perform.

Reply
  • Hi Nils,

    as you say, there are 3 Timers available on the nRF51822. In addition there are 2 RTC's. The Timers use the 16 MHz clock (HFCLK) , while the RTC's use the 32 kHz clock (LFCLK).

    When the softdevice is enabled it reserves one Timer and one RTC (in addition to other HW resources). That leaves your application with 2 Timers and 1 RTC. For PWMs you would typically use a Timer, while timekeeping is usually done with an RTC.

    If you have multiple tasks that require millisecond-resolution timing, you can look into the SDK component app_timer. App_timer uses the RTC and facilitates timed events. For example: you want to read a sensor every 10 ms, do some processing every 100 ms, and then run a 3 second timeout for something.

    To summarize: the Timers are quite generic and can be connected to different peripherals to perform different functions.It's up to your application to make sure the Timers and RTCs are allocated (and multiplexed if needed) to the different tasks you want to perform.

Children
No Data
Related