打印
[活动专区]

【AT-START-F437测评】串口

[复制链接]
673|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
目地利用串口助手打印出相关的信息
1.资料


框架

配置方法


2.原理图



4、打出的结果
发送什么,接收什么

5.代码
串口初始化
gpio_init_type gpio_init_struct;

  /* enable the usart2 and gpio clock */
  crm_periph_clock_enable(CRM_USART1_PERIPH_CLOCK, TRUE);
  crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);

  gpio_default_para_init(&gpio_init_struct);

  /* configure the usart2 tx, rx pin */
  gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
  gpio_init_struct.gpio_out_type  = GPIO_OUTPUT_PUSH_PULL;
  gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
  gpio_init_struct.gpio_pins = GPIO_PINS_9 | GPIO_PINS_10;
  gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
  gpio_init(GPIOA, &gpio_init_struct);
  gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE9, GPIO_MUX_7);
  gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE10, GPIO_MUX_7);


  /* config usart nvic interrupt */
  nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
  nvic_irq_enable(USART1_IRQn, 0, 0);

  /* configure usart2 param */
  usart_init(USART1, 115200, USART_DATA_8BITS, USART_STOP_1_BIT);
  usart_transmitter_enable(USART1, TRUE);
  usart_receiver_enable(USART1, TRUE);

  /* enable usart2 and usart3 interrupt */
  usart_interrupt_enable(USART1, USART_RDBF_INT, TRUE);
  usart_enable(USART1, TRUE);


中断
    if(usart_flag_get(USART1, USART_RDBF_FLAG) != RESET)
    {
                usart_flag_clear(USART1, USART_RDBF_FLAG);
                usart_data_transmit(USART1,usart_data_receive(USART1));
    }
//--
    if(usart_flag_get(USART1, USART_TDBE_FLAG) != RESET)
    {
        usart_flag_clear(USART1, USART_TDBE_FLAG);
    }


复位时打印
        printf ("AT-START-F437");
        printf ("\n\r");


使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

认证:工程师
简介:超越自我,为设计激发灵感和想象。

82

主题

472

帖子

2

粉丝