cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103: Option to assign pins to core M3 in CubeMX

XPChi
Associate II

Hello,
When generating code via CubeMX, the main code does not contain the configuration for the GPIO pins I need to be using.

I have checked other solutions and seen that the pins need to be assigned to the core (in this case it would be the M3). The option to do this doesn't seem to be available; is there any hidden menus I need to be looking for? 


Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

SPI pins are initialized in HAL_SPI_MspInit within the stm32f1xx_hal_msp.c file.

/**
* @brief SPI MSP Initialization
* This function configures the hardware resources used in this example
* @PAram hspi: SPI handle pointer
* @retval None
*/
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  if(hspi->Instance==SPI1)
  {
  /* USER CODE BEGIN SPI1_MspInit 0 */

  /* USER CODE END SPI1_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_SPI1_CLK_ENABLE();

    __HAL_RCC_GPIOA_CLK_ENABLE();
    /**SPI1 GPIO Configuration
    PA5     ------> SPI1_SCK
    PA6     ------> SPI1_MISO
    PA7     ------> SPI1_MOSI
    */
    GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_6;
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /* USER CODE BEGIN SPI1_MspInit 1 */

  /* USER CODE END SPI1_MspInit 1 */

  }

}

 This gets called through HAL_SPI_Init. 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6
SofLit
ST Employee

Hello,

I don't see what do you mean by "assigning a pin to core"? STM32F103 is a single core product.

Could you please elaborate so we can understand what do you want to do?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.

Thanks for your reply SofLit.

At the moment, the generated code is not initialising the GPIO pins that I've selected in the .ioc file. All it does is enable the clock access to the GPIO.
I saw someone else in the ST Community had this issue (but yes the board had multiple cores). Solved: STM32CubeIDE doesn't seem to be initialising GPIO ... - STMicroelectronics Community
Is there anything I'm missing? 


@XPChi wrote:

I saw someone else in the ST Community had this issue (but yes the board had multiple cores). Solved: STM32CubeIDE doesn't seem to be initialising GPIO ... - STMicroelectronics Community
Is there anything I'm missing? 


Indeed this is for dual core product that doesn't apply to STM32F103 products.

Could you please share your ioc file so I can have a look at and check?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
XPChi
Associate II
 
TDK
Guru

SPI pins are initialized in HAL_SPI_MspInit within the stm32f1xx_hal_msp.c file.

/**
* @brief SPI MSP Initialization
* This function configures the hardware resources used in this example
* @PAram hspi: SPI handle pointer
* @retval None
*/
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  if(hspi->Instance==SPI1)
  {
  /* USER CODE BEGIN SPI1_MspInit 0 */

  /* USER CODE END SPI1_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_SPI1_CLK_ENABLE();

    __HAL_RCC_GPIOA_CLK_ENABLE();
    /**SPI1 GPIO Configuration
    PA5     ------> SPI1_SCK
    PA6     ------> SPI1_MISO
    PA7     ------> SPI1_MOSI
    */
    GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_6;
    GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /* USER CODE BEGIN SPI1_MspInit 1 */

  /* USER CODE END SPI1_MspInit 1 */

  }

}

 This gets called through HAL_SPI_Init. 

If you feel a post has answered your question, please click "Accept as Solution".
XPChi
Associate II

I had a feeling I would kick myself after getting an answer...
Thank you