Skip to content

Conversation

jeromecoutant
Copy link
Collaborator

Description

During RTC register write, only the date and time counters are set,
the SubSecond part is reset.
In the previous implementation, there was a quite long loop (up to 1 second).

@LMESTM @c1728p9 @mattbrown015

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Breaking change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was something calling this outside a critical section?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added protection, as rtc_write and rtc_read_lp functions can update the same variables

Copy link
Contributor

@LMESTM LMESTM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request for few comments to be added

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this always fit into a uint32_t ? or would a uint64_t be required ?
Also is LP_last_RTC_time in real seconds ? or µs ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear to me what the comment says and how it relates to the code below: where is Subsecond counter reset to PREDIV_S_VALUE ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the sub-second part retrieved from and how is it computed ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is "last counter update" ? do you mean RTC_write (like application set_time()) ?
Does this comment apply here or in RTC_write function ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is RTC_time_s still in seconds ? the operation seems to mix it with sub_seconds. If so, need to rename the variable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to explain in commit message how those 3 variables are used:
LP_continuous_time : is it the time in µsec since start-up ?
RTC_time_s: the current time that was just read from RTC register ?
LP_last_RTC_time: the last time read from RTC register, either in this function, or in RTC_write() ?)
I don't undertstand the "add 24h" case ...

This fix avoid a long waiting loop in rtc_write function,
  which was not acceptable in TICKLESS context.

Implementation comments added.

Global variable name has been updated for easier maintenance:
- LPTICKER_counter is the U32 continuous tick counter
- LPTICKER_RTC_time is the RTC time used to get the time difference
   between rtc_read_lp() calls
@jeromecoutant
Copy link
Collaborator Author

@LMESTM please check updates

@NirSonnenschein
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Oct 7, 2018

Build : SUCCESS

Build number : 3274
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8286/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Oct 7, 2018

@mbed-ci
Copy link

mbed-ci commented Oct 8, 2018

@cmonr
Copy link
Contributor

cmonr commented Oct 9, 2018

/morph export-build

@mbed-ci
Copy link

mbed-ci commented Oct 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants