2017-04-21 12:35 AM
I have generated a project for an STM32F103C8T6 using CubeMX 4.20.1.
I am using i with the 1.4.0 of the STM32CubeF1 library.
I am using the unmodified generated code to send out data in the main loop.
The CubeMX configuration is the following for the pins:
I2C on PB-7 SPI on the PB3-5 (MISO is unused). The generated GPIO initialization code looks ok for me.
If the I2C1 module is enabled there is not any output on the MOSI line even if sending non 0xFF data:
I have narrowed down the source problem to the __HAL_RCC_I2C1_CLK_ENABLE in the HAL_I2C_MspInit.
If I remove that the MOSI output will work as expected. (Of course in this way the I2C peripherial will not work):
I have already checked the errata, but have not found any relevant. The generated codes seems to do what they supposed to, but I am not really sure where to look for the problem source.
Any help would be deeply appreciated!
#spi #cube-mx #stm32 #i2c #stm32f103Solved! Go to Solution.
2017-04-26 02:45 AM
Ok, a quick update: it seems that the PWM outputs (TIM1_CH1, TIM8_CH1 and TIM3_CH3) affect the behaviour of SPI1. These are bad news for me, since my board heavily relies on these PWM's; can anybody suggest me a STM32 not affected by this annoying issue?
2017-04-26 03:33 AM
You should look at
Section 2.8: Alternate function for this device.There are a few constrains on alternate function usage on this device series.
As demonstrated by the previous messages above, this is not handled automatically by CubeMx at this time (rev 4.20.1).
2017-04-26 03:40 AM
Ok, I traced back the interference to TIM8_CH1: if I don't configure it (with following code) MOSI works as expected.
/*
* Enabling TIM8 clock
*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM8, ENABLE);
/*
* Enabling GPIOC clock
*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
/*
* Configuring TIM8_CH1 on PC.06
*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
I think this is a new errata for STM32F103RET7.