AnsweredAssumed Answered

USART1 doesn't work

Question asked by Arnas Matiukas on Feb 11, 2018
Latest reply on Feb 11, 2018 by Arnas Matiukas

Hello everyone. I have encountered problem with USART1 on STM32F446RE. It seems it doesn't work for me. I have used multiple times USART2 and it works as it should, but USART1 with same configurations just refuse to work. What could be the problem?

I use STM32CubeMX v4.24.0.

 

UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2;

 

void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART2_UART_Init(void);

 

int main(void)
{
   HAL_Init();
   SystemClock_Config();
   MX_GPIO_Init();
   MX_USART1_UART_Init();
   MX_USART2_UART_Init();
   while (1)
   {
      HAL_UART_Transmit_IT(&huart1, (uint8_t *)"Hello with USART1\r\n", strlen("Hello with USART1\r\n"));
      HAL_Delay(1000);
      HAL_UART_Transmit_IT(&huart2, (uint8_t *)"Hello with USART2\r\n", strlen("Hello with USART2\r\n"));

   }

}

 

static void MX_USART1_UART_Init(void)
{

   huart1.Instance = USART1;
   huart1.Init.BaudRate = 115200;
   huart1.Init.WordLength = UART_WORDLENGTH_8B;
   huart1.Init.StopBits = UART_STOPBITS_1;
   huart1.Init.Parity = UART_PARITY_NONE;
   huart1.Init.Mode = UART_MODE_TX_RX;
   huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
   huart1.Init.OverSampling = UART_OVERSAMPLING_16;
   if (HAL_UART_Init(&huart1) != HAL_OK)
   {
      _Error_Handler(__FILE__, __LINE__);
   }

}


static void MX_USART2_UART_Init(void)
{

   huart2.Instance = USART2;
   huart2.Init.BaudRate = 115200;
   huart2.Init.WordLength = UART_WORDLENGTH_8B;
   huart2.Init.StopBits = UART_STOPBITS_1;
   huart2.Init.Parity = UART_PARITY_NONE;
   huart2.Init.Mode = UART_MODE_TX_RX;
   huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
   huart2.Init.OverSampling = UART_OVERSAMPLING_16;
   if (HAL_UART_Init(&huart2) != HAL_OK)
   {
      _Error_Handler(__FILE__, __LINE__);
   }

}

Outcomes