deshipu wrote:I'm not sure if that helps, but you can always use the _register and _flag methods on the urtc object to talk to the chip directly, and thus set whatever settings you need.
Thanks. I just started working on micropython. Your library file was very instructive
I made changes to the urtc file. Because I have the DS3231 IC on my hand, I just worked on it.
I seperated Alarm registers ,
I added a function named alarm_state() for contol the "control register"
Datasheet writes that
Alarm1 supports seconds, minutes, hours, days (or weekdays)
Alarm2 supports minutes, hours, days (or weekdays)
There are 3 conditions for the alarm to work
for Alarm1 >
INTCN = 1
A1IE = 1
A1F = 1
for Alarm2 >
INTCN = 1
A2IE = 1
A2F = 1
AxF bits in 0e register
AxIE bits in 0f register
for mute alarm, AxF must be 0
for completely stop alarm, AxIE must be 0
Code: Select all
rtc.alarm1_state(0)
rtc.alarm2_state(0)
If you want to run it again
Code: Select all
rtc.alarm1_state(1)
rtc.alarm2_state(1)
For example: (set Alarm1 30. second in every minute)
Code: Select all
>>> rtc.alarm1_time((None,None,None,None,None,None,30,None))
>>> rtc.datetime()
DateTimeTuple(year=2017, month=8, day=11, weekday=4, hour=0, minute=25, second=5, millisecond=None)
>>> kutuk(14,16)
0e | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |
------------------------------------
0f | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
------------------------------------
------------------------------------
>>> rtc.datetime()
DateTimeTuple(year=2017, month=8, day=11, weekday=4, hour=0, minute=25, second=31, millisecond=None)
>>> kutuk(14,16)
0e | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |
------------------------------------
0f | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 |
------------------------------------
------------------------------------
Mute alarm
Code: Select all
>>> rtc.alarm1(0)
>>> kutuk(14,16)
0e | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |
------------------------------------
0f | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
------------------------------------
------------------------------------
Disable alarm
Code: Select all
>>> rtc.alarm1_state(0)
>>> kutuk(14,16)
0e | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
------------------------------------
0f | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
------------------------------------
------------------------------------
Enable alarm
Code: Select all
>>> rtc.alarm1_state(1)
>>> kutuk(14,16)
0e | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |
------------------------------------
0f | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
------------------------------------
------------------------------------
I've added the file