Hi,
I genareted a basic test project with stm32MXcube. I2C is active only. But i can not debug this project. After remap command (__HAL_AFIO_REMAP_I2C1_ENABLE();) shutting down debug session.
MCU: STM32F103VCT6 Debugger: ST-LINK/V2
I am using this wires:
1-PA14/SWCLK 2-PA13/SWDIO 3-NRST 4-VDD 5-VSS
PB9/SDA PB8/SCL
If i don't use remap command ( PB7/SDA, PB6/SCL ) there is no any problem.
Please help me.
Thank you.
When i generate same project for STM32f103RBT6 using MXcube, the problem does not occur on STM32f103RBT6 board. But same code download to STM32F103VCT6 boards shutting down debug session. I have different STM32F103VCT6 boards. Thanks
I have a similar problem with a board with an STM32F100RC. The debugger stops when MX_I2C1_Init() is called.
__HAL_AFIO_REMAP_I2C1_ENABLE();
is expanded to
SET_BIT(AFIO->MAPR, AFIO_MAPR_I2C1_REMAP)
but the SET_BIT macro can't be called with the register AFIO->MAPR Bits 24-26 of this register are write only so you can't use a read/modify/write instruction on this register.
I solved the problem using this instruction instead:
AFIO->MAPR = (AFIO->MAPR & (!AFIO_MAPR_SWJ_CFG_Msk)) | AFIO_MAPR_SWJ_CFG_JTAGDISABLE | AFIO_MAPR_I2C1_REMAP;
Use at your own risk ;-)
P.S. or instead of SET_BIT/CLEAR_BIT a MODIFY_REG macro should always be used with register AFIO->MAPR