Skip to content

FspTimer does not initialize properly if AGT timer is selected. #120

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

Merged
merged 1 commit into from
Sep 4, 2023

Conversation

KurtE
Copy link
Contributor

@KurtE KurtE commented Sep 2, 2023

If the begin method:

/* -------------------------------------------------------------------------- */
bool FspTimer::begin(timer_mode_t mode, uint8_t tp, uint8_t channel, float freq_hz, float duty_perc, GPTimerCbk_f cbk /*= nullptr*/ , void *ctx /*= nullptr*/  ) {
/* -------------------------------------------------------------------------- */

Is called with the tp=1 (AGT)
It will fail as this method uses the member variable type to decide if it is working with GPT or AGT. Problem is that this member is not set until after the code has decided that the parameters are correct and it then calls the begin with the period counts.

So needed to use the passed in parameter tp instead. Also this begin method called set_period_counts to convert the data into the counts. This method also relied on the member type. So changed it to pass in the tp parameter.

More details are in the forum thread:
https://forum.arduino.cc/t/fsptimer-using-agt-timer-issues/1164494

If the begin method:
```
/* -------------------------------------------------------------------------- */
bool FspTimer::begin(timer_mode_t mode, uint8_t tp, uint8_t channel, float freq_hz, float duty_perc, GPTimerCbk_f cbk /*= nullptr*/ , void *ctx /*= nullptr*/  ) {
/* -------------------------------------------------------------------------- */
```
Is called with the tp=1 (AGT)
It will fail as this method uses the member variable type to decide if it is
working with GPT or AGT.  Problem is that this member is not set until after the code has decided that the parameters are correct and it then calls the begin with the period counts.

So needed to use the passed in parameter tp instead.  Also  this begin
method called set_period_counts to convert the data into the counts.  This method also relied on the member type.  So changed it to pass in the tp parameter.

More details are in the forum thread:
https://forum.arduino.cc/t/fsptimer-using-agt-timer-issues/1164494
@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Sep 3, 2023
@facchinm
Copy link
Member

facchinm commented Sep 4, 2023

Super, thanks for the fix! Merging

@facchinm facchinm merged commit a8b9006 into arduino:main Sep 4, 2023
@KurtE KurtE deleted the FspTimer_AGT branch September 4, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants