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

need real time clock tutorial for s130 nr51822

Is there a simple way to have linux time up and running with minimum current consumption and good accuracy?

Preferably, some class with get_unix_time and set_unix_time methods, with a resolution of up to seconds.

Parents
  • Hi

    I did a simple example using the time.h library a while back, and you might be able to use that as a basis:
    https://github.com/NordicPlayground/nrf5-calendar-example

    I only included project files for the nRF52 series though, but the code should be backwards compatible with the nRF51822.

    The accuracy will depend on your 32kHz clock source. If you use the external 32k crystal on the nRF51 DK it will be 20ppm at room temperature.

    Best regards
    Torbjørn

  • I DO need to get some clock for my health device., I need to provide timestamps with measurements. However, your example requires that the user input an initial time. No user of a device would ever want to do that every time the device is turned on.

    How would I implement a timer that needs to be set only once and then continues every time the device is turned on. There must be some way to this as I have never used a health device that doesn't keep its time between power cycles.

    I am using an nRF51822 on the corresponding DK. I would like to be using the nRF52 series but that is not in my power to choose. If I could do this entirely by using SoftDevice (s130) sd_* calls that would be even better.

    Thanks

Reply
  • I DO need to get some clock for my health device., I need to provide timestamps with measurements. However, your example requires that the user input an initial time. No user of a device would ever want to do that every time the device is turned on.

    How would I implement a timer that needs to be set only once and then continues every time the device is turned on. There must be some way to this as I have never used a health device that doesn't keep its time between power cycles.

    I am using an nRF51822 on the corresponding DK. I would like to be using the nRF52 series but that is not in my power to choose. If I could do this entirely by using SoftDevice (s130) sd_* calls that would be even better.

    Thanks

Children
  • Hi

    By "device is turned on" do you mean that the device is woken up from some sleep state (while the chip still has a power supply) or that the device is powered up completely?

    In order for the device to keep track of time when it is off the nRF chip will need to have power, and run an RTC timer in the background (using the 32kHz crystal as a clock source). 

    If you remove power from the device completely there is no way to keep track of time. If you save a timestamp to flash before the device is powered off you can continue from that point when you wake up again, but the time spent without power will obviously not be counted. 

    brianreinhold said:
    I have never used a health device that doesn't keep its time between power cycles.

    Not sure what system you are talking about here, but I don't know of any electronic system that can keep track of time without power. 

    More sophisticated devices with rechargeable batteries might include a secondary smaller battery for the sole purpose of keeping track of time when the main battery is discharged, but then they will probably also use a dedicated RTC chip separated from the main processor. 

    Best regards
    Torbjørn

  • I guess my question really comes down to this: Does the chip have a built in CMOS timer? If not, then it's pretty clear what needs to be done. Some source of power must be provided.

  • Hi

    The chip has built in clock sources both for the LF clock and the HF clock, but they both require a power supply, and they are not very accurate (5-10% deviation worst case). 

    In other words there is no way for the chip to track time without a power supply, and there is no way for the chip to accurately track time without an external crystal. 

    Best regards
    Torbjørn

Related