---
title: "Comment by Wang MaoMao on \"Embedded Rust & Embassy: PWM Generation\" | Hashnode"
description: "Thanks! This series is really helpful. I followed this PWM tut with my STM32WLE5x board using PB3, TIM2_CH2. One thing I notice is that Delay hangs the program."
url: "https://hashnode.com/posts/embedded-rust-embassy-pwm-generation/638e065090845e1bd201fb6d/comment/63c4ef1fd72a4e43689dbc74"
---

[Discussion](https://hashnode.com/posts/embedded-rust-embassy-pwm-generation/638e065090845e1bd201fb6d)

Comment [Embedded Rust & Embassy: PWM Generation](https://hashnode.com/posts/embedded-rust-embassy-pwm-generation/638e065090845e1bd201fb6d)

[Wang MaoMao](https://hashnode.com/@andelf)

[Jan 16, 2023](https://hashnode.com/posts/embedded-rust-embassy-pwm-generation/638e065090845e1bd201fb6d/comment/63c4ef1fd72a4e43689dbc74)

Thanks! This series is really helpful. I followed this PWM tut with my STM32WLE5x board using PB3, TIM2\_CH2. One thing I notice is that `Delay` hangs the program. A workaround is using `cortex_m::delay::Delay`.

[Omar Hiari](https://hashnode.com/@omarhiari)

[Jan 16, 2023](https://hashnode.com/posts/embedded-rust-embassy-pwm-generation/638e065090845e1bd201fb6d/comment/63c4ef1fd72a4e43689dbc74#reply-63c4f1ccd72a4e43689dbcfe)

Thank you for the feedback, Wang! You probably noticed that I used `embassy_time::Delay` to implement a blocking delay, which also required me to import `embedded_hal::blocking::delay::DelayMs`. My guess is that what's happening could have to do with the embedded\_hal implementation for `DelayMs` on the particular device you are using. Either way, what you are doing is a totally valid alternative to generate a blocking delay, however, instead using the Cortex-M core crate.

[Wang MaoMao](https://hashnode.com/@andelf)

[Jan 20, 2023](https://hashnode.com/posts/embedded-rust-embassy-pwm-generation/638e065090845e1bd201fb6d/comment/63c4ef1fd72a4e43689dbc74#reply-63cac5ca587fc59d3cd73850)

[Omar Hiari](https://hashnode.com/@omarhiari) Finally I figured out why the `embassy_time::Delay` does not work. It is implemented using `embassy_time::Instant`, which uses `TIM2`(`time-driver-any` feature). My selected PWM pin(TIM2\_CH2) also uses the `TIM2` timer, so the instant value resets at each PWM cycle, resulting in an unusable `Instant`. Never mind, `cortex_m::delay::Delay` works great.

[Omar Hiari](https://hashnode.com/@omarhiari)

[Jan 21, 2023](https://hashnode.com/posts/embedded-rust-embassy-pwm-generation/638e065090845e1bd201fb6d/comment/63c4ef1fd72a4e43689dbc74#reply-63cbc058587fc59d3cd74c6e)

Awesome [Wang MaoMao](https://hashnode.com/@andelf)! I'm glad you figured it out!

Following the source of these problems is not much fun sometimes.
