Skip to content

tmrctr: initialize PWM and timer state variables#383

Open
FloofyJin wants to merge 1 commit into
Xilinx:masterfrom
FloofyJin:fix-tmrctr-uninitialized-state
Open

tmrctr: initialize PWM and timer state variables#383
FloofyJin wants to merge 1 commit into
Xilinx:masterfrom
FloofyJin:fix-tmrctr-uninitialized-state

Conversation

@FloofyJin

Copy link
Copy Markdown

XTmrCtr_CfgInitialize() does not initialize IsStartedTmrCtr0, IsStartedTmrCtr1, or IsPwmEnabled.

When XTmrCtr instances are allocated on the stack, these members may contain indeterminate values.

This can cause XTmrCtr_PwmEnable() to return without enabling PWM because IsPwmEnabled is non-zero.

Reproduction:

XTmrCtr Timer;
XTmrCtr_Initialize(&Timer, DEVICE_ID);
XTmrCtr_PwmConfigure(...);
XTmrCtr_PwmEnable(&Timer);

The issue disappears if the application performs memset(&Timer, 0, sizeof(Timer)) prior to initialization. This patch initializes the driver state variables inside XTmrCtr_CfgInitialize() which will essentially do the same thing.

@sivadur

sivadur commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

@FloofyJin Thanks for reporting it. We will check and fix if this turns to be a real issue.

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