jayanth.devarayanadurga
Banned
- Joined
- Dec 4, 2012
- Messages
- 4,280
- Helped
- 822
- Reputation
- 1,654
- Reaction score
- 791
- Trophy points
- 1,393
- Location
- Bangalore, India
- Activity points
- 0
Are you telling that I have to write 0 to 6th bit to get PM and 1 to get AM?
The DS1307 can be run in either 12-hour or 24-hour mode.
Bit 6 of the hours register is defined as the 12-hour or
24-hour mode-select bit. When high, the 12-hour mode
is selected. In the 12-hour mode, bit 5 is the AM/PM bit with
logic high being PM. In the 24-hour mode, bit 5 is the second
10-hour bit (20 to 23 hours). The hours value must be
re-entered whenever the 12/24-hour mode bit is changed.
Edit: I think this is causing the problem.
*hr = ((*hr & 0x30) >> 4)*10 + (*hr & 0x0F); //instruction in Transform_Time()
Maybe this is for 24 bit format. What should I use for 12 hour format?
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 void Transform_Time(char *sec, char *min, char *hr, char *week_day, char *day, char *mn, char *year) { *sec = ((*sec & 0x70) >> 4)*10 + (*sec & 0x0F); *min = ((*min & 0xF0) >> 4)*10 + (*min & 0x0F); //*hr = ((*hr & 0x30) >> 4)*10 + (*hr & 0x0F); //24 hr mode if((*hr & 0b01100000) == 0b01100000)am_pm = 1; // 12 hr mode else am_pm = 0; if((*hr & 0b00010000) == 0b00010000)*hr = 10 + (*hr & 0x0F); else if((*hr & 0b00010000) == 0b00000000)*hr = 0 + (*hr & 0x0F); *week_day =(*week_day & 0x07); *day = ((*day & 0xF0) >> 4)*10 + (*day & 0x0F); *mn = ((*mn & 0x10) >> 4)*10 + (*mn & 0x0F); *year = ((*year & 0xF0)>>4)*10+(*year & 0x0F); }
//*******************************************************************************
// writes the time and date into the DS1302
void ClockSet()
{
RTCWriteArray[2] = ((PCRxBuffer[1] - '0') & 0x03) << 4; // hours tens
RTCWriteArray[2] |= (PCRxBuffer[2] - '0') & 0x0F; // hours units
RTCWriteArray[1] = ((PCRxBuffer[3] - '0') & 0x07) << 4; // mins tens
RTCWriteArray[1] |= (PCRxBuffer[4] - '0') & 0x0F; // mins units
RTCWriteArray[0] = ((PCRxBuffer[5] - '0') & 0x07) << 4; // secs tens
RTCWriteArray[0] |= (PCRxBuffer[6] - '0') & 0x0F; // secs units
RTCWriteArray[3] = ((PCRxBuffer[7] - '0') & 0x03) << 4; // days tens
RTCWriteArray[3] |= (PCRxBuffer[8] - '0') & 0x0F; // days units
RTCWriteArray[4] = ((PCRxBuffer[9] - '0') & 0x01) << 4; // month tens
RTCWriteArray[4] |= (PCRxBuffer[10] - '0') & 0x0F; // month units
RTCWriteArray[6] = ((PCRxBuffer[11] - '0') & 0x0F) << 4; // year tens
RTCWriteArray[6] |= (PCRxBuffer[12] - '0') & 0x0F; // years units
BurstWrite1302();
SyncWith1302();
UpdateLCDClock();
UpdateOSDClock();
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?