PSOC 4 RTC AM_PM Flag in 24 hour mode

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaMi_4139556
Level 1
Level 1
First like received

Hello All,

Quick question that I am pretty certain I know the answer but I don't see it spelled out clearly in the RTC_P4_v1_20.pdf document.

When in 24 hour clock mode does the AM_PM flag get set when the time is between 12:00 & 23:59:59?

I am pretty certain the answer is "no" but I also don't see it clearly defined in the datasheet.  So I thought I would check with the community.

Thanks,

Dave

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I've just checked with RTC_P4_V1_10 in PSoC Creator v4.2 with a project for CY8C4247AZI-M485 (CY8CKIT-044)

If with "AM_PM flag" you meant is the bit 22 of dateTime->time which is acquired from

RTC_UnixToDateTime() function, I think that you are correct.

In RTC_UnixToDateTime() the variable tmpAmPmState is initialized as 0u. (line 1377 of RTC.c)

And only when timeFormat is not RTC_24_HOURS_FORMAT (line 1426 of RTC.c)

tmpAmPmState has chance to be assigned RTC_PM (line 1430 of RTC.c).

Then for the dataTime->time, RTC_ConstructTime is called with the 2nd argument "tmpAmPmState",

which is always 0 when date format is RTC_24_HOURS_FORMAT ,

so there will not be a chance to get that bit be set in RTC_ConstructTime(). (line 1450 of RTC.c)

moto

View solution in original post

0 Likes
2 Replies
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

I've just checked with RTC_P4_V1_10 in PSoC Creator v4.2 with a project for CY8C4247AZI-M485 (CY8CKIT-044)

If with "AM_PM flag" you meant is the bit 22 of dateTime->time which is acquired from

RTC_UnixToDateTime() function, I think that you are correct.

In RTC_UnixToDateTime() the variable tmpAmPmState is initialized as 0u. (line 1377 of RTC.c)

And only when timeFormat is not RTC_24_HOURS_FORMAT (line 1426 of RTC.c)

tmpAmPmState has chance to be assigned RTC_PM (line 1430 of RTC.c).

Then for the dataTime->time, RTC_ConstructTime is called with the 2nd argument "tmpAmPmState",

which is always 0 when date format is RTC_24_HOURS_FORMAT ,

so there will not be a chance to get that bit be set in RTC_ConstructTime(). (line 1450 of RTC.c)

moto

0 Likes

Thanks for checking, you verified what I expected and I am seeing.

As I mentioned the documents infer that the AM_PM flag may not be used but do not explicitly state it and as you know that sometimes doesn't mean anything.

Thanks again and I will just handle AM_PM detection by using RTC_GetHours() and checking for 12 or higher.

Dave