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

twi interfacing with RTC DS1307

please suggest me some API's to interface nrf51422 with RTC DS1307

Parents
  • I have not found a library that will drop directly into the SDK, but there are several libraries out there that you can look at for inspiration. You will also want to look at the TWI master driver for handling the I2C communication with the DS1307.

    If you intend to power the nRF at all times (which is the case for most products), it could be an option to use the internal RTC instead of a external RTC. You would have to handle the complexities of date and time, such as adjusting for months with fewer than 31 days and corrections for leap year in software, but the accuracy will be just as good as using the DS1307 (as it only depends on the 32 kHz crystal).

  • Which SDK version are you using? (The is_busy flag has not been used since SDK 10, so I will assume you are using version 10.)

    If you are using the driver in blocking mode (as it looks like you are doing from the code snippet in an earlier comment where you supplied NULL as the event_handler), is_busy should never be set to true. The only exception I can think of is if you initiate another transfer before the first has finished, which is a bit odd since the call is blocking, but it could happen if you call the driver from two different interrupt priorities (for example from the main context and an event handler).

Reply
  • Which SDK version are you using? (The is_busy flag has not been used since SDK 10, so I will assume you are using version 10.)

    If you are using the driver in blocking mode (as it looks like you are doing from the code snippet in an earlier comment where you supplied NULL as the event_handler), is_busy should never be set to true. The only exception I can think of is if you initiate another transfer before the first has finished, which is a bit odd since the call is blocking, but it could happen if you call the driver from two different interrupt priorities (for example from the main context and an event handler).

Children
No Data
Related