Skip to content

[bug] Updates the power API to correct a frequency update related bug.#156

Open
luizvilla wants to merge 1 commit into
owntech-foundation:mainfrom
luizvilla:setFrenquency
Open

[bug] Updates the power API to correct a frequency update related bug.#156
luizvilla wants to merge 1 commit into
owntech-foundation:mainfrom
luizvilla:setFrenquency

Conversation

@luizvilla

Copy link
Copy Markdown
Member

Context

When frequency is updated, the duty cycle is not.

This means that when updating the duty cycle the period is not refreshed and the values passed to the spin API were wrong.

Correction

I've created a setFrenquency, getFrequency and getFrenquecyMin so that the user can manipulate the frequency with better ease.

Tests

I've built and tested it with the test code that will be attached on the next message.

When frequency is updated, the duty cycle is not. This means that when updating the duty cycle the period is not refreshed and the values passed to the spin API were wrong.
@luizvilla

Copy link
Copy Markdown
Member Author

All files necessary for flashing are here.

src.zip

I have not tested with other examples.

@Ayoub-Farah Ayoub-Farah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Functionally, this is okay, but it would be useful to add in the doxygen comments that setFrequency() must not be called with a frequency lower than the value returned by getFrequencyMin(), and that this minimum frequency is initialized from the Device Tree min-frequency property.

@Ayoub-Farah Ayoub-Farah self-requested a review July 6, 2026 12:57
void PowerAPI::setFrequency(uint32_t frequency)
{
spin.pwm.setFrequency(frequency);
timer_frequency = frequency;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

spin.pwm.setFrequency can clamp the minimal frequency value, but timerFrequency is getting the original frequency input.
There is a need to clamp it to timer_frequency_min if frequency is inferior to that value.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants