AnsweredAssumed Answered

uart hal library

Question asked by valencia.juan on Dec 21, 2014
Latest reply on Feb 10, 2016 by corporate.divum

It seems keil is forcing me to use the hal libraries and i'm triying to work with them.
i've spent hours triying to make an uart com work.

i've tried the example from the STM32cube_F4 and it works but when i try to do it in my own template it won't work.

/* Private define ------------------------------------------------------------*/
    /* Definition for USARTx clock resources */
    #define USARTx                           USART3
    #define USARTx_CLK_ENABLE()              __USART3_CLK_ENABLE();
    /* Definition for USARTx Pins */
      #define    USARTx_TX_PIN            GPIO_PIN_8
      #define    USARTx_TX_AF             GPIO_AF7_USART3
      #define    USARTx_TX_GPIO_PORT      GPIOD
    /* Definition for USARTx's NVIC */
     #define    USARTx_IRQn               USART3_IRQn
     #define    USARTx_IRQHandler         USART3_IRQHandler
void UART3_INIT (unsigned int baud){
    GPIO_InitTypeDef  GPIO_InitStruct;
    /* UART RX GPIO pin configuration  */
    GPIO_InitStruct.Pin       = USARTx_TX_PIN;
  GPIO_InitStruct.Mode      = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull      = GPIO_NOPULL;
  GPIO_InitStruct.Speed     = GPIO_SPEED_FAST;
  GPIO_InitStruct.Alternate = USARTx_TX_AF;
    /* Put the USART peripheral in the Asynchronous mode (UART Mode) */
    UartHandle.Instance        = USARTx;
  UartHandle.Init.BaudRate   = baud;
  UartHandle.Init.WordLength = UART_WORDLENGTH_8B;
  UartHandle.Init.StopBits   = UART_STOPBITS_1;
  UartHandle.Init.Parity     = UART_PARITY_NONE;
  UartHandle.Init.HwFlowCtl  = UART_HWCONTROL_NONE;
  UartHandle.Init.Mode       = UART_MODE_TX;
    /* NVIC for USART1 */
    HAL_NVIC_SetPriority(USARTx_IRQn, 0, 1);
  * @brief  This function handles UART interrupt request. 
  * @param  None
  * @retval None
  * @Note   used for USART data transmission    
void USARTx_IRQHandler(void)
uint8_t aTxBuffer[] = "Title";
/*Send a Message*/
HAL_UART_Transmit_IT(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE);

With this code i receive some werd chracters such as "ü".

i've tried to measure the frequency of my code and it varies between 700 - 1500 hz. The cube_F4 example it does between 3500-4000 Hz.

I think the clock configuration is ok, i tested it with a timer...

Does anyone know what the problem might be?