cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED] STM32F103CB chip TIM1 & SPI2 conflict

VL.3
Associate III

Hey!

I initialized the TIM1 peripheral to output an complementary PWN signal on channel 2 (PB14) and tested it with an oscilloscope. Signal is present, everything's fine.
Then after initialization of the SPI2 peripheral (PB13 & PB15) PWM signal is no longer visible on pin. 

I use CubeMX for code generation and specific line where PWM output "dies" is this:

 

void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
{
...
__HAL_RCC_SPI2_CLK_ENABLE(); // <- here
...
}

 

I can toggle SPI2EN bit inside APB1ENR register in Debug mode and see the same outcome:

Screenshot.png

Now I'm lost what to do next. PCB is already made and I need both TIM1 and SPI2. Workaround in my case would be hand-written SPI which I try to avoid of course.

Any suggestions?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

This is consequence of the rather peculiar GPIO arrangement of the 'F1 (every other STM32 uses a different, more complete GPIO matrix). Basically, as soon as you enable SPI2, it occupies pins PB13, PB14 and PB15 and there's no workaround to it. Some peripherals can be remapped to other pins, but not SPI2.

JW

View solution in original post

2 REPLIES 2

This is consequence of the rather peculiar GPIO arrangement of the 'F1 (every other STM32 uses a different, more complete GPIO matrix). Basically, as soon as you enable SPI2, it occupies pins PB13, PB14 and PB15 and there's no workaround to it. Some peripherals can be remapped to other pins, but not SPI2.

JW

Thanks!