cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo STM32F411 pins not working when alternate functions

RBran.3
Associate II

It seems that I'm having problems with the pins configured as alternate function.

If I configure the same pins used by SPI or USART as simple gpio outputs, I can see them toggling with the logic analyser. but when I configure them as SPI (alternate function) or USART they are not working as expected. I have tried changing SPI creating an stm32 project, configuring the pins through the GUI and using the HAL_APIs. the result is the same : I can see the pins toggle when configured as gpio outputs, I can't see anything when configured as SP or USART.

I have checked with the debug and the SPI and USART registers are configured as expected.

am I missing something?

5 REPLIES 5

> I have checked with the debug and the SPI and USART registers are configured as expected.

Post, together with the relevant GPIO registers content.

JW

RBran.3
Associate II

 0693W00000BbnADQAZ.png 0693W00000BbnEKQAZ.png0693W00000BbnEUQAZ.png0693W00000BbnEeQAJ.png0693W00000BbnEjQAJ.pngthis is the code I used for test:

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);
 
  uart_buf_len=sprintf(uart_buf, "SPI Test\n");
 
  HAL_UART_Transmit(&huart2, (uint8_t *)uart_buf, uart_buf_len, 100);
 
  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
 
  HAL_SPI_Transmit(&hspi1, (uint8_t *)uart_buf, uart_buf_len, 100);
 
  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);

the only thing that I see changing in the logic analyser is the PB6

RBran.3
Associate II

with the code above I connected TeraTerm using ST-Link virtual com. I can see the message displayed in the console:

0693W00000BbqULQAZ.png 

but the logic analyser on pins PA2 and PA3 shows no traffic

Then the logic analyzer is not connected to pins PA2 and PA3.

They may be brought out to the pinheaders through jumpers/solder bridges which are not connected by default.

0693W00000BbqXKQAZ.png 

JW

RBran.3
Associate II

I managed to make it work using USART1 on pins pa9 and pa10 and SP1 on pins pa5,pa6,pa7 and pb6 (/CS)