Skip to main content
Jun 29, 2021 11:56 AM UTC
Question

Setting up SPI of stm32f205 for ads1118

I am trying to set up SPI according to datasheet .

Here is the datasheet recomendation:

0693W00000BcJLDQA3.pngthe pin that is connected to DRDY is the SPI MISO pin. But on CubeMX I can not change the GPIO mode. There is available only one mode: Alternate Function Push Pull. How to solve this?

This topic has been closed for replies.

5 replies

waclawek.jan
Super User
Jun 29, 2021 12:30 PM UTC

Which STM32?

A pin set to AF can still be used also as EXTI, it's just CubeMX which does not support this.

Program the pin as AF as usually, and then set directly in SYSCFG and EXTI registers as appropriate for the EXTI functionality.

JW

PS. This is a recurring question here, try searching; one of the hints is https://community.st.com/s/question/0D50X0000ADB3vsSQD/how-to-enable-external-interrupt

Jun 29, 2021 12:37 PM UTC

stm32f205

Jun 29, 2021 2:21 PM UTC

@Community member​  have you ever solved this before?

waclawek.jan
Super User
Jun 29, 2021 3:39 PM UTC

Yes, but I don't use CubeMX.

JW

Jun 29, 2021 9:41 PM UTC

I gave a look at spi file after generation and I found this:

/**SPI3 GPIO Configuration

  PA15   ------> SPI3_NSS

  PC10   ------> SPI3_SCK

  PC11   ------> SPI3_MISO

  PC12   ------> SPI3_MOSI

  */

  GPIO_InitStruct.Pin = GPIO_PIN_15;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

  GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;

  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

  GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;

  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

I changed GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; to GPIO_MODE_AF_PP|GPIO_MODE_IT_FALLING|GPIO_MODE_AF_PP; to set up the mode of only pin c11 but it seems not working