Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem with low level lp_ticker STM wrapper #11385

Merged
merged 2 commits into from
Sep 5, 2019

Conversation

Tharazi97
Copy link
Contributor

Description

Fixes #11373

I have changed the STM implementation of low level lp ticker wrapper in way that it checks if event gets outdated while waiting for CMPOK flag. I have also added a solution of handling events that are close to ticker counter roll over. It changes the base of the timestamp so it can be easily compared with other values around max counter value.

/* Change the lp_delayed_counter buffor in that way so the value of (0xFFFF - LP_TIMER_SAFE_GUARD) is equal to 0.
             * By doing this it is easy to check if the value of timestamp get outdated by delaying its programming
             * For example if LP_TIMER_SAFE_GUARD is set to 5
             * (0xFFFA + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF = 0
             * (0xFFFF + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF = 5
             * (0x0000 + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF = 6
             * (0x0005 + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF = 11*/
            lp_delayed_counter = (timestamp + LP_TIMER_SAFE_GUARD + 1) & 0xFFFF;

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@maciejbocianski @mprse @jamesbeyond @LMESTM @0xc0170

Release Notes

@ciarmcom
Copy link
Member

@Tharazi97, thank you for your changes.
@mprse @maciejbocianski @jamesbeyond @0xc0170 @ARMmbed/mbed-os-maintainers please review.

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.

I think this change makes sense and is properly described ... thank you
2 minor remarks / questions

/* If this target timestamp is close to the roll over of the ticker counter
* and current tick is also close to the roll over, then we are in danger zone.*/
if(((0xFFFF - LP_TIMER_SAFE_GUARD < timestamp) || (timestamp < LP_TIMER_SAFE_GUARD))
&& ((0xFFFA < last_read_counter) || (last_read_counter < LP_TIMER_SAFE_GUARD)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the condition (last_read_counter < LP_TIMER_SAFE_GUARD) also needed ?
If this is the case, then the rollover already happened, right ?
I don't think it would cause an issue though ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. It could do some mess if you want to set timestamp to 0xFFFF, or something close to, and current tick is at the beginning of the counter.

&& ((0xFFFA < last_read_counter) || (last_read_counter < LP_TIMER_SAFE_GUARD)))
{
roll_over_flag = true;
/* Change the lp_delayed_counter buffor in that way so the value of (0xFFFF - LP_TIMER_SAFE_GUARD) is equal to 0.
Copy link
Contributor

Choose a reason for hiding this comment

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

type buffor / buffer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mbed-ci
Copy link

mbed-ci commented Sep 2, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

/* If this target timestamp is close to the roll over of the ticker counter
* and current tick is also close to the roll over, then we are in danger zone.*/
if(((0xFFFF - LP_TIMER_SAFE_GUARD < timestamp) || (timestamp < LP_TIMER_SAFE_GUARD)) && (0xFFFA < last_read_counter))
{
Copy link
Contributor

Choose a reason for hiding this comment

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

please fix the style in the file (=consistency)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@jamesbeyond jamesbeyond left a comment

Choose a reason for hiding this comment

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

look good

@0xc0170 0xc0170 requested a review from a team September 4, 2019 12:08
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 4, 2019

Started CI

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.

Thanks a lot !

@mbed-ci
Copy link

mbed-ci commented Sep 4, 2019

Test run: FAILED

Summary: 1 of 11 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_mbed2-build-ARM

@Tharazi97
Copy link
Contributor Author

CI fail seems not related.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 5, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Sep 5, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 3
Build artifacts

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.

Lp_ticker problem
7 participants