[AT32F403/403A] AT32F403A USART1回环测试出现丢失第一个字节问题

[复制链接]
 楼主| hedan12 发表于 2023-12-12 10:22 | 显示全部楼层 |阅读模式
  1. void wk_usart1_init(void)
  2. {
  3.   crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE);
  4.   crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
  5.   crm_periph_clock_enable(CRM_USART1_PERIPH_CLOCK, TRUE);
  6.   
  7.   gpio_init_type gpio_init_struct;
  8.   gpio_default_para_init(&gpio_init_struct);

  9.   /* configure the TX pin */
  10.   gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
  11.   gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
  12.   gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
  13.   gpio_init_struct.gpio_pins = GPIO_PINS_9;
  14.   gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
  15.   gpio_init(GPIOA, &gpio_init_struct);

  16.   /* configure the RX pin */
  17.   gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
  18.   gpio_init_struct.gpio_out_type  = GPIO_OUTPUT_PUSH_PULL;
  19.   gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
  20.   gpio_init_struct.gpio_pins = GPIO_PINS_10;
  21.   gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
  22.   gpio_init(GPIOA, &gpio_init_struct);
  23.    
  24.   /* configure param */
  25.   usart_init(USART1, 115200U, USART_DATA_8BITS, USART_STOP_1_BIT);
  26.   usart_transmitter_enable(USART1, TRUE);
  27.   usart_receiver_enable(USART1, TRUE);

  28. #if USE_IDLE_DMA
  29.   usart_dma_receiver_enable(USART1, TRUE);
  30. #endif
  31.   
  32.   nvic_irq_enable(USART1_IRQn, 1, 0);
  33.   
  34. #if USE_IDLE_DMA
  35.   usart_interrupt_enable(USART1, USART_IDLE_INT, TRUE);
  36. #else
  37.   usart_interrupt_enable(USART1, USART_RDBF_INT, TRUE);
  38. #endif
  39.   
  40.   usart_enable(USART1, TRUE);
  41. }
发送123vh,第一次能全部返回,后面再发送就辉丢失第一个字节,格式是123vh23vh23vh....
muyichuan2012 发表于 2023-12-12 11:10 | 显示全部楼层
可以用逻辑分析仪把TX脚波形抓一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

4

主题

7

帖子

0

粉丝
快速回复 返回顶部 返回列表