2022-11-12 05:04 AM
STM32Cube FW_F1 V1.8.4
Conditions:
SPI1 or SPI3 remapped to PB3-5 pins.
Problem:
SPI not work.
Solution:
Enable Debug Serial Wire (PA13 PA14)
SWJ function changes SWJ_CFG[2:0] bits
stm32f1xx_hal_msp.c line 81
__HAL_AFIO_REMAP_SWJ_NOJTAG();
do{ uint32_t tmpreg = ((AFIO_TypeDef *)((0x40000000UL + 0x00010000UL) + 0x00000000UL))->MAPR; \
tmpreg &= ~(0x7UL << (24U)); \
tmpreg |= (0x1UL << (25U)); \
((AFIO_TypeDef *)((0x40000000UL + 0x00010000UL) + 0x00000000UL))->MAPR = tmpreg; \
}while(0u)
For some reasons SPI remap function changes SWJ_CFG[2:0] bits too, somehow it depend on previous state of SWJ_CFG.
stm32f1xx_hal_msp.c line 121
__HAL_AFIO_REMAP_SPI1_ENABLE();
do{ uint32_t tmpreg = ((AFIO_TypeDef *)((0x40000000UL + 0x00010000UL) + 0x00000000UL))->MAPR; \
tmpreg |= (0x7UL << (24U)); \
tmpreg |= (0x1UL << (0U)); \
((AFIO_TypeDef *)((0x40000000UL + 0x00010000UL) + 0x00000000UL))->MAPR = tmpreg; \
}while(0u)
2022-11-12 06:18 AM
The F1 series is old and clumsy.
Yes remapping often requires attention, if you map functionality to a particular block of pins you might need to map other functionality off those same pins to avoid conflicts.
Much is likely to be flagged in errata, etc, at this point.