Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

24 to 12 hour
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

24 to 12 hour

by LitingWolf on Sat Feb 08, 2020 8:59 pm

I have ds3231 rtc how do I change to 12 hour I know I have to change the bit but I don't know how to do that

LitingWolf
 
Posts: 37
Joined: Thu Jan 02, 2020 3:03 pm

Re: 24 to 12 hour

by LitingWolf on Sat Feb 08, 2020 9:44 pm

im using the adafruit rtc3231 lib

LitingWolf
 
Posts: 37
Joined: Thu Jan 02, 2020 3:03 pm

Re: 24 to 12 hour

by adafruit_support_mike on Sun Feb 09, 2020 3:58 am

The CircuitPython module for the DS3231 doesn't have a function that changes the 12/24 setting, so you'll have to add one.

The instructions from the Register module explain how to do that in general terms:

https://github.com/adafruit/Adafruit_Ci ... n_Register

adafruit_support_mike
 
Posts: 61407
Joined: Thu Feb 11, 2010 2:51 pm

Re: 24 to 12 hour

by LitingWolf on Sun Feb 09, 2020 9:07 am

Its Adafruit DS3231 Precision RTC Breakout the one i have

LitingWolf
 
Posts: 37
Joined: Thu Jan 02, 2020 3:03 pm

Re: 24 to 12 hour

by adafruit_support_bill on Sun Feb 09, 2020 9:31 am

Without knowing what language you are programming in, it is hard to provide specific advice. If programming in Python, you need to use the Registers module as Mike suggests. If programming in Arduino, you can use Wire._I2C_WRITE(). The 12/24 hour mode selection bit is bit 6 of register 0.02 as detailed on page 11 of the data sheet.
https://cdn-shop.adafruit.com/product-f ... DS3231.pdf

Note that changing the mode of the chip may confuse other functions in the library that may be expecting things in 24 hour mode.

A simpler approach is to just leave the chip the default mode and handle it in your code:

something like:
Code: Select all | TOGGLE FULL SIZE
if (hour > 12
{
    hour = hour - 12;
    PM = true;
}

adafruit_support_bill
 
Posts: 78635
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.