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

Calculate DCRi using CTR0 #471

Open
crawfxrd opened this issue Jul 2, 2024 · 1 comment
Open

Calculate DCRi using CTR0 #471

crawfxrd opened this issue Jul 2, 2024 · 1 comment

Comments

@crawfxrd
Copy link
Member

crawfxrd commented Jul 2, 2024

The PWMi Duty Cycle output = (DCRi)/(CTR+1)
If the DCRi value > CTR value, PWMi signal is still low.
If DCRi value = CTR value, PWMi signal is still high.

Use Cycle Time Register to determine the PWM value that should be used for DCRi.

#define PWM_DUTY(X) ((uint8_t)(((((uint16_t)(X)) * 255) + 99) / 100))

255 (0xFF) here should be CTR0.

@crawfxrd
Copy link
Member Author

crawfxrd commented Jul 8, 2024

The problem right now is that PWM_DUTY is used in the fan tables (__code), so it must be a fixed value (which obviously means it can't read from the register).

At the very least, a comment should be added that the 0xFF is the fixed value for CTR0, and that any change to CTR in pwm_init() must be updated here.

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

No branches or pull requests

1 participant