Skip to content

Commit

Permalink
attiny85: pwm: Add PWM support for PB3
Browse files Browse the repository at this point in the history
PB3 on is the "Complementary Timer/Counter1 Compare Match B Output",
which can be used a PWM, but has the reverse polarity.
  • Loading branch information
sjoerdsimons committed Feb 7, 2024
1 parent e312e6e commit caea11f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mcu/attiny-hal/src/simple_pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ avr_hal_generic::impl_simple_pwm! {

#[cfg(feature = "attiny85")]
avr_hal_generic::impl_simple_pwm! {
/// Use `TC1` for PWM (pins `PB4`)
/// Use `TC1` for PWM (pins `~PB3`, `PB4`)
///
/// # Example
/// ```
Expand All @@ -154,6 +154,15 @@ avr_hal_generic::impl_simple_pwm! {
});
},
pins: {
PB3: {
ocr: ocr1b,
into_pwm: |tim | if enable {
tim.gtccr.modify(|_, w| w.com1b().bits(0b01));
} else {
tim.gtccr.modify(|_, w| w.com1b().disconnected());
},
},

PB4: {
ocr: ocr1b,
into_pwm: |tim| if enable {
Expand Down

0 comments on commit caea11f

Please sign in to comment.