Merge pull request #4132 from GreatKet/main

Dead-time computation in complementary PWM fixed
This commit is contained in:
Dario Nieuwenhuis 2025-04-25 12:51:45 +00:00 committed by GitHub
commit 572e788b2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -240,11 +240,11 @@ fn compute_dead_time_value(value: u16) -> (Ckd, u8) {
let (these_bits, result) = if target < 128 {
(target as u8, target)
} else if target < 255 {
(64 + (target / 2) as u8, (target - target % 2))
((64 + (target / 2) as u8) | 128, (target - target % 2))
} else if target < 508 {
(32 + (target / 8) as u8, (target - target % 8))
((32 + (target / 8) as u8) | 192, (target - target % 8))
} else if target < 1008 {
(32 + (target / 16) as u8, (target - target % 16))
((32 + (target / 16) as u8) | 224, (target - target % 16))
} else {
(u8::MAX, 1008)
};
@ -300,7 +300,7 @@ mod tests {
TestRun {
value: 400,
ckd: Ckd::DIV1,
bits: 32 + (400u16 / 8) as u8,
bits: 210,
},
TestRun {
value: 600,