I have installed the DS3231 RTC breakout as per the instructions on the Learn section of Adafruit on a Rpi B+. However, after completing the final steps I was left a little bit hanging in that accessing the built-in functions such as the alarm triggers nor reading or controlling the output from the 32k SQW were not covered.
My current needs are a high-accuracy event trigger so I have used some other tutorials to sync my board with the PPS-GPS time and chrony which so far seems to be working:
trigger@gpstrigger:~ $ timedatectl
Local time: Sun 2022-03-20 21:53:18 GMT
Universal time: Sun 2022-03-20 21:53:18 UTC
RTC time: Sun 2022-03-20 21:53:18
Time zone: Europe/London (GMT, +0000)
System clock synchronized: yes
NTP service: inactive
RTC in local TZ: no
trigger@gpstrigger:~ $ chronyc tracking
Reference ID : 50505300 (PPS)
Stratum : 1
Ref time (UTC) : Sun Mar 20 21:54:03 2022
System time : 0.000000077 seconds slow of NTP time
Last offset : -0.000000091 seconds
RMS offset : 0.000717191 seconds
Frequency : 4.979 ppm fast
Residual freq : -0.000 ppm
Skew : 0.001 ppm
Root delay : 0.000000001 seconds
Root dispersion : 0.000022166 seconds
Update interval : 16.0 seconds
Leap status : Normal
My events need to be triggered off of GPS timing preferably -0ms/+100us and IMHO setting a hardware clock to do the triggering is preferable to having a program looping to compare datetimes. Wouldn't catching a GPIO going high/low since they are already polled about every 5us make more sense?trigger@gpstrigger:~ $ chronyc sources
210 Number of sources = 11
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#x NMEA 0 4 377 17 +132ms[ +132ms] +/- 68ms
#* PPS 0 4 377 17 -1927ns[-2309ns] +/- 237ns
^- time-a-b.nist.gov 1 7 377 48 +5128us[+5128us] +/- 69ms
^- time-d-b.nist.gov 1 6 377 56 -2830us[-2830us] +/- 66ms
I have tried to read the memory registers of the chip using smbus but I am currently getting
which I thought was a bit wierd.OSError: [Errno 16] Device or resource busy
Does anyone have any thoughts on how to communicate with the RTC to make use of the in-built functions such as alarms and the like?
System Information
------------------
Raspberry Pi 3 Model B Plus Rev 1.3
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"