[N32G45x] 官方串口打印功能验证没成功

[复制链接]
 楼主| zhouchen605768 发表于 2022-11-20 13:12 | 显示全部楼层 |阅读模式
大家有没有验证基于官方的串口打印的例子,基于开发板N32G45XRL-STB开发板.验证失败的,下面是我验证的代码添加:

void RCC_Configuration(void)
{
  RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA|RCC_APB2_PERIPH_AFIO,ENABLE); //enable GPIOA  clk
  RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_USART1,ENABLE);                     //enable usart1 clk
}



#define USARTx_GPIO    GPIOA
#define USART_Tx_Pin   GPIO_PIN_9
#define USART_Rx_Pin   GPIO_PIN_10

void GPIO_Configuration(void)
{
          GPIO_InitType GPIO_InitStructure;

    /* Configure USARTx Tx as alternate function push-pull */
    GPIO_InitStructure.Pin        = USART_Tx_Pin;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;       //这个地方换过了几种 GPIO_Mode_Out_OD ,GPIO_Mode_AF_OD,GPIO_Mode_AF_PP     

    GPIO_InitPeripheral(USARTx_GPIO, &GPIO_InitStructure);

    /* Configure USARTx Rx as input floating */
    GPIO_InitStructure.Pin       = USART_Rx_Pin;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
    GPIO_InitPeripheral(USARTx_GPIO, &GPIO_InitStructure);
       
}



USART_InitType USART_InitStructure;
void USART_Printf_Configuration(void)
{
       
    /* USARTy and USARTz configuration ------------------------------------------------------*/
    USART_InitStructure.BaudRate            = 115200;
    USART_InitStructure.WordLength          = USART_WL_8B;
    USART_InitStructure.StopBits            = USART_STPB_1;
    USART_InitStructure.Parity              = USART_PE_NO;
    USART_InitStructure.HardwareFlowControl = USART_HFCTRL_NONE;
    USART_InitStructure.Mode                = USART_MODE_RX | USART_MODE_TX;

    /* Configure USARTx */
    USART_Init(USART1, &USART_InitStructure);
    /* Enable the USARTx */
    USART_Enable(USART1, ENABLE);
}


主函数处理:
int main(void)
{       
        RCC_Configuration();
        GPIO_Configuration();
        USART_Printf_Configuration();
                        printf("N32G45RE printf test.\r\n");
        while(1)
        {
                printf("N32G45RE printf test.\r\n");
                Delay(0x28ffff);
        }
}


测试结果无任何的打印数据,有谁知道是什么原因.

 楼主| zhouchen605768 发表于 2022-11-20 23:08 | 显示全部楼层
现在验证ok了,
sy12138 发表于 2022-11-21 13:59 | 显示全部楼层

例程是没有问题的,需要看一下开发板跳线对不对
GGG3 发表于 2022-11-22 09:45 | 显示全部楼层
官方例程,尤其是这么基础的,一般是不会出错的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

18

主题

81

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部