美文网首页
2. HelloWorld - UART

2. HelloWorld - UART

作者: T_K_233 | 来源:发表于2020-05-23 15:44 被阅读0次

UART 设置如下

image.png
int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */
  

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USART2_UART_Init();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */
 
 

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
    char str[] = "123321";
    HAL_UART_Transmit(&huart2, (uint8_t *) str, strlen(str), 10);
    HAL_UART_Transmit(&huart2, "\r\n", 2, 10);
  }
  /* USER CODE END 3 */
}

相关文章

网友评论

      本文标题:2. HelloWorld - UART

      本文链接:https://www.haomeiwen.com/subject/jacgohtx.html