News:

Let's find out together what makes a PIC Tick!

Main Menu

DS1307 12 hour mode

Started by RGV250, Sep 10, 2026, 09:43 AM

Previous topic - Next topic

RGV250

Hi,
I have the DS1307 clock working (from the inc file here) https://protoncompiler.com/index.php/topic,1655.0.html
The problem is I cannot get it working in 12 hour mode.
On the start up I write
    DS1307_WriteRegister(2,64)                   ' Set the clock module to 12 hour mode (reg 2, bit 6)

I added this to the DS1307.INC file so I can test for reg 2, bit 5 in the program.

'----------------------------------------------------------------------------
' Read the Time
' Input     : None
' Output    : Variable RTC_bSecond holds the seconds value (in decimal)
'           : Variable RTC_bMinute holds the minutes value (in decimal)
'           : Variable RTC_bHour holds the hours value (in decimal)
' Notes     : None
'
Proc DS1307_ReadTime()
    I2CIn DS1307_SDA_Pin, DS1307_SCL_Pin, cRTC_DEV_ADDR, cRTC_TIME, [RTC_bSecond,
                                                                     RTC_bMinute,
                                                                     RTC_bHour]
    RTC_AM_PM = RTC_bHour   ' Added to confirm the clock is in 12 hour mode
    RTC_bSecond = DS1307_BCDToDec(RTC_bSecond)      ' Convert the Seconds value to decimal
    RTC_bMinute = DS1307_BCDToDec(RTC_bMinute)      ' Convert the Minutes value to decimal
    RTC_bHour   = DS1307_BCDToDec(RTC_bHour)        ' Convert the Hours value to decimal

EndProc

But nothing changes, I am wondering if this is another sim issue.

Regards,
Bob

Pepe

demo   proteus 12h-24h with les library modyfied

RGV250

Thanks, there was a lot more work than I had though of.

Regards,
Bob