You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently got an XL density stm32f103 (stm32f103RGT6) and ran into a pretty strange issue.
When running the following code, the debugger stops responding and I have to reboot the microcontroller with BOOT0 pulled high in order to reflash it. The issue happens when configuring serial, when configuring SPI1 but not when configuring SPI2.
If mapr.mapr().modify(|_, w| w.spi1_remap().bit(PINS::REMAP)); is removed from spi.rs, things work fine which is a pretty clear indication that it is responsible.
Finally, removing disable_jtag also makes things work as normal
#![deny(unsafe_code)]#![no_main]#![no_std]use panic_semihosting as _;use stm32f1xx_hal::{
prelude::*,
pac,
serial::{Config,Serial},
spi::{Spi,Mode,Polarity,Phase}};use cortex_m_rt::entry;#[entry]fnmain() -> ! {// Get access to the device specific peripherals from the peripheral access cratelet p = pac::Peripherals::take().unwrap();letmut flash = p.FLASH.constrain();letmut rcc = p.RCC.constrain();let clocks=rcc.cfgr.freeze(&mut flash.acr);// Prepare the alternate function I/O registersletmut afio = p.AFIO.constrain(&mut rcc.apb2);// Prepare the GPIOB peripheralletmut gpioa = p.GPIOA.split(&mut rcc.apb2);letmut gpiob = p.GPIOB.split(&mut rcc.apb2);let(pa15, pb3, pb4) = afio.mapr.disable_jtag(gpioa.pa15, gpiob.pb3, gpiob.pb4);/* let right_usart = Serial::usart1( p.USART1, ( gpioa.pa9.into_alternate_push_pull(&mut gpioa.crh), gpioa.pa10, ), &mut afio.mapr, Config::default().baudrate(921_600.bps()), clocks, &mut rcc.apb2, ); */let mode = Mode{phase:Phase::CaptureOnFirstTransition,polarity:Polarity::IdleLow};let pins = (
gpioa.pa5.into_alternate_push_pull(&mut gpioa.crl),
gpioa.pa6,
gpioa.pa7.into_alternate_push_pull(&mut gpioa.crl),);let mode = Mode{phase:Phase::CaptureOnFirstTransition,polarity:Polarity::IdleLow};let spi = Spi::spi1(p.SPI1, pins,&mut afio.mapr, mode,1.khz(), clocks,&mut rcc.apb2);/* { let pins = ( gpiob.pb13.into_alternate_push_pull(&mut gpiob.crh), gpiob.pb14, gpiob.pb15.into_alternate_push_pull(&mut gpiob.crh), ); let spi = Spi::spi2(p.SPI2, pins, mode, 1.khz(), clocks, &mut rcc.apb1); } */loop{}}
The same code works perfectly fine on the standard blue pill boards. This might also be a hardware issue, however as far as I know, the debug circuit on my custom PCB is the same as the blue pill.
The text was updated successfully, but these errors were encountered:
I recently got an XL density stm32f103 (stm32f103RGT6) and ran into a pretty strange issue.
When running the following code, the debugger stops responding and I have to reboot the microcontroller with BOOT0 pulled high in order to reflash it. The issue happens when configuring serial, when configuring SPI1 but not when configuring SPI2.
If
mapr.mapr().modify(|_, w| w.spi1_remap().bit(PINS::REMAP));
is removed fromspi.rs
, things work fine which is a pretty clear indication that it is responsible.Finally, removing
disable_jtag
also makes things work as normalThe same code works perfectly fine on the standard blue pill boards. This might also be a hardware issue, however as far as I know, the debug circuit on my custom PCB is the same as the blue pill.
The text was updated successfully, but these errors were encountered: