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

adc.rs: fix channel -> smp register mismatch #291

Merged
merged 1 commit into from
Oct 23, 2021

Conversation

Lotterleben
Copy link
Contributor

While read()ing a Pin mapped to channel 10 we got an (unexpected to us) panic:

 ERROR panicked at 'internal error: entered unreachable code', /Users/lottesteenbrink/.cargo/git/checkouts/stm32f3xx-hal-bb439b50181a2760/6997410/src/adc.rs:610:1
└─ panic_probe::print_defmt::print @ /Users/lottesteenbrink/.cargo/registry/src/github.com-1ecc6299db9ec823/panic-probe-0.2.1/src/lib.rs:95
────────────────────────────────────────────────────────────────────────────────
(HOST) WARN  no RAM region appears to contain the stack; cannot determine if this was a stack overflow
stack backtrace:
   0: HardFaultTrampoline
      <exception entry>
   1: lib::inline::__udf
        at ./asm/inline.rs:172:5
   2: __udf
        at ./asm/lib.rs:49:17
   3: cortex_m::asm::udf
        at /Users/lottesteenbrink/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.7.3/src/asm.rs:43:5
   4: rust_begin_unwind
        at /Users/lottesteenbrink/.cargo/registry/src/github.com-1ecc6299db9ec823/panic-probe-0.2.1/src/lib.rs:76:9
   5: core::panicking::panic_fmt
        at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   6: core::panicking::panic
        at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   7: stm32f3xx_hal::adc::Adc<stm32f3::stm32f303::ADC3>::set_chan_smps
        at /Users/lottesteenbrink/.cargo/git/checkouts/stm32f3xx-hal-bb439b50181a2760/6997410/src/adc.rs:509:30
   8: stm32f3xx_hal::adc::Adc<stm32f3::stm32f303::ADC3>::convert_one
        at /Users/lottesteenbrink/.cargo/git/checkouts/stm32f3xx-hal-bb439b50181a2760/6997410/src/adc.rs:471:21
   9: <stm32f3xx_hal::adc::Adc<stm32f3::stm32f303::ADC3> as embedded_hal::adc::OneShot<stm32f3::stm32f303::ADC3,Word,Pin>>::read
        at /Users/lottesteenbrink/.cargo/git/checkouts/stm32f3xx-hal-bb439b50181a2760/6997410/src/adc.rs:538:35
        
 [... backtrace dives into our own code from here]

Which from my understanding is caused by a channel/SMP Register mismatch in set_chan_smps(). This PR fixes that.

@Sh3Rm4n Sh3Rm4n self-requested a review October 22, 2021 13:20
@Sh3Rm4n
Copy link
Member

Sh3Rm4n commented Oct 23, 2021

Thanks for fixing this oversight! 👍

I guess, this would be a candidate for backporting to v0.8, to release it earlier, as breaking changes are already on the master. I'll add it to my to-do list.

@Sh3Rm4n Sh3Rm4n merged commit c99fd56 into stm32-rs:master Oct 23, 2021
@Sh3Rm4n Sh3Rm4n added this to the v0.8.1 milestone Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants