0

I want to Initialize and send a single int using UART in blue_pill (STM32F10C8). Manual ask to set GPIO mode on ALTRN_PULL_PUSH in blue_pill. But Low level HALL library dosn't have such a option. Here is my code for initializing the UART:

void uart2_init()
{
    LL_APB1_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
    LL_APB1_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
    LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_9, LL_GPIO_MODE_ALTERNATE);  // ***this line should be corrected***
    LL_GPIO_SetPinSpeed(GPIOA, LL_GPIO_PIN_9, LL_GPIO_MODE_OUTPUT_50MHz);
    LL_USART_SetTransferDirection(USART1, LL_USART_DIRECTION_TX);
    LL_USART_ConfigCharacter(USART1, LL_USART_DATAWIDTH_8B, LL_USART_PARITY_NONE, LL_USART_STOPBITS_1);
    LL_USART_SetBaudRate (USART1, 8000000, 9600);
    LL_USART_Enable(USART1);
}

I need to set pin mode to "LL_GPIO_MODE_ALTERNATE_PUSH_PULL" but the library dosn't provide it. Can anyone correct me?

glts
  • 21,808
  • 12
  • 73
  • 94

1 Answers1

0

I think you should use LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType) function.

Which allows You to set output type of pin as :

  • LL_GPIO_OUTPUT_PUSHPULL
  • LL_GPIO_OUTPUT_OPENDRAIN

I am highly recommend You to search this kind of information in - UM1850, where You can find a lot of information, for e.g. there is a information about above function on page 807.

Lime7
  • 31
  • 3
  • STM in page 30 of this application note [AN4904] (https://www.st.com/resource/en/application_note/an4904-migration-of-microcontroller-applications-from-stm32f1-series-to-stm32f4-access-lines-stmicroelectronics.pdf) ask to define the Tx pin as altenate push pull. In the example code is 'GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;' but I cannot find equivalent Low LEVEL Hall library in UM1850 application note. – user1482636 Aug 14 '22 at 04:11