2021-06-23 02:45 AM
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?
2021-06-23 04:27 AM
> 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
2021-06-23 05:28 AM
this 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
2021-06-23 02:58 PM
with the code above I connected TeraTerm using ST-Link virtual com. I can see the message displayed in the console:
but the logic analyser on pins PA2 and PA3 shows no traffic
2021-06-23 03:06 PM
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.
JW
2021-06-24 01:34 AM
I managed to make it work using USART1 on pins pa9 and pa10 and SP1 on pins pa5,pa6,pa7 and pb6 (/CS)