---
title: "Discussion on \"STM32F4 Embedded Rust at the HAL: Timer Interrupts\" | Hashnode"
description: "Discussion on \"STM32F4 Embedded Rust at the HAL: Timer Interrupts\". This blog post is the second of a three-part series of posts where I explore interrupts for the STM32F401RE microcontroller using embedded Rust at the HAL level.\n\nAs a word of note, this post heavily"
url: "https://hashnode.com/posts/stm32f4-embedded-rust-at-the-hal-timer-interrupts/630cc3b556df9e8e502523bf"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [STM32F4 Embedded Rust at the HAL: Timer Interrupts](https://blog.theembeddedrustacean.com/stm32f4-embedded-rust-at-the-hal-timer-interrupts?utm_source=hashnode&utm_medium=feed)

This blog post is the second of a three-part series of posts where I explore interrupts for the STM32F401RE microcontroller using embedded Rust at the HAL level. As a word of note, this post heavily

Aug 29, 2022 · 19 min read · blog.theembeddedrustacean.com  
Updated Aug 3  
Read the article

-   [#rust](https://hashnode.com/tag/rust)
-   [#tutorial](https://hashnode.com/tag/tutorial)
-   [#embedded](https://hashnode.com/tag/embedded)
-   [#beginner](https://hashnode.com/tag/beginner)

## Written by

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

@omarhiari

  
[View profile](https://hashnode.com/@omarhiari)

I am an 📟 Embedded Engineer with years of experience in both industry 🏭 and academia 🏫. Passionate Mentor 👨‍💼 and Instructor 👨‍🏫. Rustacean 🦀

## Responses 3

Markdown supported · ⌘↵ to post

[Andrey](https://hashnode.com/@hawaiian)

[Feb 3, 2025](https://hashnode.com/posts/stm32f4-embedded-rust-at-the-hal-timer-interrupts/630cc3b556df9e8e502523bf/comment/67a0a6c840988f0f9f286ed6)

Hello, thanks for the article! I'm trying to set a low value for timer it panics, e.g.

`timer.start(100.millis()).unwrap();`

I'm using STM32F103C8T6. Any thoughts on why?

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

[Feb 3, 2025](https://hashnode.com/posts/stm32f4-embedded-rust-at-the-hal-timer-interrupts/630cc3b556df9e8e502523bf/comment/67a0a6c840988f0f9f286ed6#reply-67a0a884e6c76c8e06618c2f)

Hello [Andrey](https://hashnode.com/@hawaiian), it's been a while since I worked with STM32s and Rust, though could you possibly share what the panic message says? It's possible that it would say that you are unwrapping an error variant.

Since the `start` method returns a `Result`, maybe you can use a `match` statement to print out the error as well. This could give some indication.

[Andrey](https://hashnode.com/@hawaiian)

[Feb 3, 2025](https://hashnode.com/posts/stm32f4-embedded-rust-at-the-hal-timer-interrupts/630cc3b556df9e8e502523bf/comment/67a0a6c840988f0f9f286ed6#reply-67a0e52f52e680d5e965c3f7)

I found out the issue, it's newbee one :) I enabled interrupts early and it ISR is called before I initialized a device, working with that device caused an error. Thanks for the response and the blog!

[rain silent](https://hashnode.com/@silentrains)

[Aug 22, 2023](https://hashnode.com/posts/stm32f4-embedded-rust-at-the-hal-timer-interrupts/630cc3b556df9e8e502523bf/comment/64e42b1a965997cb76b4e6de)

This article is very impressive I am studying STM32F103C8T6 and looking for examples related to external clock sources based on timers. Can you please publish a similar article?

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

[Aug 24, 2023](https://hashnode.com/posts/stm32f4-embedded-rust-at-the-hal-timer-interrupts/630cc3b556df9e8e502523bf/comment/64e42b1a965997cb76b4e6de#reply-64e6ee7b06aee9f0bdb500ba)

Hello, [rain silent](https://hashnode.com/@silentrains) I am glad you liked it. One thing I wanted to do in the past related to your request is input capture to measure the frequency of external clock sources. It turns out at the time that the feature was not yet supported in various STM32 HALs. Nevertheless, it can still be done with software and GPIO. A very similar post you might find useful is the ultrasonic distance measurement, as it achieves something quite similar. Here is the link: [apollolabsblog.hashnode.dev/stm32f4-embedded-rust…](https://apollolabsblog.hashnode.dev/stm32f4-embedded-rust-at-the-hal-timer-ultrasonic-distance-measurement)

[Eleftheria Batsou](https://hashnode.com/@eleftheriabatsou)

[Aug 30, 2022](https://hashnode.com/posts/stm32f4-embedded-rust-at-the-hal-timer-interrupts/630cc3b556df9e8e502523bf/comment/630db05156df9e8e50254c61)

Great work once again [Omar Hiari](https://hashnode.com/@omarhiari)!

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

[Aug 30, 2022](https://hashnode.com/posts/stm32f4-embedded-rust-at-the-hal-timer-interrupts/630cc3b556df9e8e502523bf/comment/630db05156df9e8e50254c61#reply-630db4e356df9e8e50254dba)

Thank you Eleftheria!
