CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PCF8583 and 12hr time format

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








PCF8583 and 12hr time format
PostPosted: Fri Feb 12, 2010 5:26 pm     Reply with quote

Hello,

I have a question about the PCF8583 RTC working in 12hr time format.

The PCF8583 spread sheet states the following: In the clock modes 24 h or 12 h format can be selected by
setting the most significant bit of the hours counter
register.


hours counter:
_______________________
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
--------------------------------

Bit 7: format:
0 - 24h format, AM/PM flag remains unchanged
1 - 12h format, AM/PM flag will be updated

Bit 6 : AM/PM flag:
0 - AM | 1 - PM

Bits[5 -4]: ten hours (0 to 2 binary)

Bits[3-0]: unit hours BCD

Now here is my question, if I set bit #7 on the hour counter (for 12h time format), will the PCF8583 change automatically to "12 hour" format the bits[5 - 0] (including bit#6, AM/PM flag) or I have to convert the format from 24hr to 12hr by code?
(HOURS: bits [3 - 0] in BCD)

any help much appreciated,

thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 12, 2010 5:38 pm     Reply with quote

The easiest way to find out would be to just test it. Set it up for 1700
hours in 24 Hr mode. Read and display the time. Then set the bit to
put it in 12 Hr mode. Read the time again and see if it changed to 5 pm.
ozzie2005



Joined: 11 Dec 2006
Posts: 5

View user's profile Send private message

PostPosted: Fri Feb 12, 2010 6:52 pm     Reply with quote

Hi PCM programmer,
I did test it that way. In fact I use part of your library PCM programmer. Just changing the bit #7, PCF8583 will not convert the time format for you ( or I think it does not), so I decided to do it by code (which I think the chip should be able to do that) but for some reason when I change it from 12 back to 24 format, I cant read the AM/PM flag.

I was wondering if someone has some experience working with the PCF8583 in 12hr format.

PS. Is the AM/PM bit Writable (bit#6)

thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Feb 13, 2010 1:21 am     Reply with quote

If someone else doesn't help you first, I'll look at it later in the weekend.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sat Feb 13, 2010 8:08 am     Reply with quote

The AM/PM bit should be read- and writable in 12h mode.

If you proceed like this:
- read time
- change mode
- write time (according to the new mode)
doesn't it work?
ozzie2005



Joined: 11 Dec 2006
Posts: 5

View user's profile Send private message

PostPosted: Sat Feb 13, 2010 11:11 am     Reply with quote

Hi PC Progammer / FvM,

Thanks for your replies, after testing and making some changes in my code, I found out where the problem was in my code. When changing the format from 24 ->12h and then back to 24h (toggle switch), I was masking these two bits with the wrong mask.

Just for future reference and in case someone has the same question, with the PCF8583, your code has to take care of these flags (12/24hr, AM/PM bits) and also convert the time from 24->12hr format and viceversa.

...and yes, the AM/PM flag (bit#6) is readable and writable. You have to change this flag accordingly.


thank you guys!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group