Skip to main content
vekli
Associate II
November 12, 2022
Question

Bug STM32F107RCTx SPI REMAPPED NOT WORK

  • November 12, 2022
  • 1 reply
  • 651 views

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)

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
November 12, 2022

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.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..