stm32f103xx-hal
stm32f103xx-hal copied to clipboard
Error when doing PB8.into_alternate_open_drain
I'm trying to put PB8 into alternate open drain mode, so I can use it for I2C.
37 // Get access to PORTB pins
38 let mut gpiob = dp.GPIOB.split(&mut rcc.apb2);
39
40 // We want to use pin PB8 as SCL1 and PB9 as SDA1
41 let scl1 = gpiob.pb8.into_alternate_open_drain(&mut gpiob.crh);
42 let sda1 = gpiob.pb9.into_alternate_open_drain(&mut gpiob.crh);
When I run this in GDB, something crashes and the asm::bkpt()
default handler is called.
Program received signal SIGTRAP, Trace/breakpoint trap.
cortex_m_rt::default_handler (ef=0x20004d80) at /home/danilo/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rt-0.3.13/src/lib.rs:664
664 asm::bkpt();
(gdb) bt
#0 cortex_m_rt::default_handler (ef=0x20004d80) at /home/danilo/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rt-0.3.13/src/lib.rs:664
#1 <signal handler called>
#2 0x08001830 in <stm32f103xx_hal::gpio::gpiob::PB8<MODE>>::into_alternate_open_drain (self=..., cr=0x20004e78)
at /home/danilo/.cargo/git/checkouts/stm32f103xx-hal-7d0db38b85df9102/80b2099/src/gpio.rs:191
#3 0x0800249e in bluepill_sgp30::main () at src/main.rs:41
Any idea what the reason for this could be? I'm still quite new to microcontrollers with the complexity of a Cortex M3 :)