CH32V208W的debug里面的printf無(wú)法輸出單個(gè)字符串

使用EVT里面的GPIO_Toggle中使用下面的串口測(cè)試程序,發(fā)現(xiàn)printf無(wú)法將數(shù)據(jù)通過(guò)WCH-link的串口發(fā)送到上位機(jī),但是USART3卻可以。

有問(wèn)題是下面這行:

? ? ? ? printf("%c", d);

如果改成了,下面這樣,又可以打印出來(lái)了,這個(gè)是什么原因呢?

? ? ? ? printf("%c\r\n", d);


USART3可以的代碼片段是:

USART_SendData(USART3,?d);


復(fù)現(xiàn)這個(gè)問(wèn)題,可以將下面的代碼片段替換GPIO_Toggle的main.c:


/**********************************?(C)?COPYRIGHT?*******************************
?*?File?Name??????????:?main.c
?*?Author?????????????:?WCH
?*?Version????????????:?V1.0.0
?*?Date???????????????:?2021/06/06
?*?Description????????:?Main?program?body.
?*?Copyright?(c)?2021?Nanjing?Qinheng?Microelectronics?Co.,?Ltd.
?*?SPDX-License-Identifier:?Apache-2.0
?*******************************************************************************/
/*
?*@Note
?GPIO例程:
?PA0推挽輸出。
?*/
#include?"debug.h"
/*?Global?define?*/
/*?Global?Variable?*/
void?USART3_IRQHandler(void)?__attribute__((interrupt("WCH-Interrupt-fast")));
/*********************************************************************
?*?@fn??????GPIO_Toggle_INIT
?*
?*?@brief???Initializes?GPIOA.0
?*
?*?@return??none
?*/
void?GPIO_Toggle_INIT(void)?{
????GPIO_InitTypeDef?GPIO_InitStructure?=?{?0?};
????RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,?ENABLE);
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_0?|?GPIO_Pin_1;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_Out_PP;
????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
????GPIO_Init(GPIOA,?&GPIO_InitStructure);
}
void?USART3_Init(void)?{
????int?parity?=?USART_Parity_No;
????//ToDo:?for?RS485?in?nonParity?stop?bit?should?be?2
????int?stopBit?=?USART_StopBits_1;
????int?dataBit?=?USART_WordLength_8b;
????u32?ulBaudRate?=?9600;
????GPIO_InitTypeDef?GPIO_InitStructure?=?{?0?};
????USART_InitTypeDef?USART_InitStructure?=?{?0?};
????NVIC_InitTypeDef?NVIC_InitStructure?=?{?0?};
????RCC_APB1PeriphClockCmd(
#ifdef?USE_UART2
????????????RCC_APB1Periph_USART2?|
#endif
????RCC_APB1Periph_USART3,?ENABLE);
????//RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA?|?RCC_APB2Periph_GPIOB,?ENABLE);
????RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,?ENABLE);
#ifdef?USE_UART2
????/*?USART2?TX-->A.2???RX-->A.3?*/
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_2;
????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP;
????GPIO_Init(GPIOA,?&GPIO_InitStructure);
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_3;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IN_FLOATING;
????GPIO_Init(GPIOA,?&GPIO_InitStructure);
#endif
????/*?USART3?TX-->B.10??RX-->B.11?*/
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_10;
????GPIO_InitStructure.GPIO_Speed?=?GPIO_Speed_50MHz;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_AF_PP;
????GPIO_Init(GPIOB,?&GPIO_InitStructure);
????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_11;
????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IN_FLOATING;
????GPIO_Init(GPIOB,?&GPIO_InitStructure);
????//?ULONG?ulBaudRate,?UCHAR?ucDataBits,?eMBParity?eParity
????USART_InitStructure.USART_BaudRate?=?ulBaudRate;?//115200;
????USART_InitStructure.USART_WordLength?=?dataBit;?//USART_WordLength_8b;
????USART_InitStructure.USART_StopBits?=?stopBit;?//USART_StopBits_1;
????USART_InitStructure.USART_Parity?=?parity;?//USART_Parity_No;
????USART_InitStructure.USART_HardwareFlowControl?=
????USART_HardwareFlowControl_None;
????USART_InitStructure.USART_Mode?=?USART_Mode_Tx?|?USART_Mode_Rx;
#ifdef?USE_UART2
????USART_Init(USART2,?&USART_InitStructure);
????USART_ITConfig(USART2,?USART_IT_RXNE,?ENABLE);
#endif
????USART_Init(USART3,?&USART_InitStructure);
????USART_ITConfig(USART3,?USART_IT_RXNE,?ENABLE);
#ifdef?USE_UART2
????NVIC_InitStructure.NVIC_IRQChannel?=?USART2_IRQn;
????NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?1;
????NVIC_InitStructure.NVIC_IRQChannelSubPriority?=?1;
????NVIC_InitStructure.NVIC_IRQChannelCmd?=?ENABLE;
????NVIC_Init(&NVIC_InitStructure);
#endif
????NVIC_InitStructure.NVIC_IRQChannel?=?USART3_IRQn;
????NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority?=?2;
????NVIC_InitStructure.NVIC_IRQChannelSubPriority?=?2;
????NVIC_InitStructure.NVIC_IRQChannelCmd?=?ENABLE;
????NVIC_Init(&NVIC_InitStructure);
#ifdef?USE_UART2
????USART_Cmd(USART2,?ENABLE);
#endif
????USART_Cmd(USART3,?ENABLE);
}
/*********************************************************************
?*?@fn??????USART3_IRQHandler
?*
?*?@brief???This?function?handles?USART3?global?interrupt?request.
?*
?*?@return??none
?*/
void?USART3_IRQHandler(void)?{
????//printf("IRQ\r\n");
????//RX?not?empty,?data?came
????if?(USART_GetITStatus(USART3,?USART_IT_RXNE)?!=?RESET)?{
????????u16?d?=?USART_ReceiveData(USART3);
????????printf("%c",?d);
????????USART_SendData(USART3,?d);
????????//USART_ClearITPendingBit(USART3,?USART_IT_RXNE);
????}
????//USART_IT_TC?or?USART_IT_TXE?
????//?TC:?tramsimit?done
????//?USART_IT_TXE?:?TX?done,?TX?buffer?empty
????//??From?name?"prvvUARTTxReadyISR"?should?be?the?TXE
????else?if?(USART_GetITStatus(USART3,?USART_IT_TC)?!=?RESET)?{
????????printf("U3?IRQ?TX\r\n");
????????USART_ClearITPendingBit(USART3,?USART_IT_TC);
????}?else?{
????????printf("U3?Interrupt?flag:\r\n");
????????if?(USART_GetITStatus(USART3,?USART_IT_CTS)?!=?RESET)?{
????????????printf("?USART_IT_CTS?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_LBD)?!=?RESET)?{
????????????printf("?USART_IT_LBD?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_TXE)?!=?RESET)?{
????????????printf("?USART_IT_TXE?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_TC)?!=?RESET)?{
????????????printf("?USART_IT_LBD?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_IDLE)?!=?RESET)?{
????????????printf("?USART_IT_IDLE?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_ORE_RX)?!=?RESET)?{
????????????printf("?USART_IT_ORE_RX?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_ORE_ER)?!=?RESET)?{
????????????printf("?USART_IT_ORE_ER?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_NE)?!=?RESET)?{
????????????printf("?USART_IT_NE?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_FE)?!=?RESET)?{
????????????printf("?USART_IT_FE?");
????????}?else?if?(USART_GetITStatus(USART3,?USART_IT_PE)?!=?RESET)?{
????????????printf("?USART_IT_PE?");
????????}?else?{
????????????printf("Other?UART?Flag\r\n");
????????}
????????printf("\r\n");
????}
}
/*********************************************************************
?*?@fn??????main
?*
?*?@brief???Main?program.
?*
?*?@return??none
?*/
int?main(void)?{
????u8?i?=?0;
????u8?j?=?1;
????NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
????Delay_Init();
????USART3_Init();
????USART_Printf_Init(115200);
????printf("SystemClk:%d\r\n",?SystemCoreClock);
????printf("GPIO?Toggle?TEST\r\n");
????GPIO_Toggle_INIT();
????while(1)
????{
????????Delay_Ms(250);
????????GPIO_WriteBit(GPIOA,?GPIO_Pin_0,?(i?==?0)???(i?=?Bit_SET)?:?(i?=?Bit_RESET));
????????//GPIO_WriteBit(GPIOA,?GPIO_Pin_1,?(j?==?0)???(j?=?Bit_SET)?:?(j?=?Bit_RESET));
????}
}


從你這邊描述的現(xiàn)象來(lái)看,可能與勾選的打印配置有關(guān),可以按照下方鏈接勾選配置。

有關(guān)MounRiver打印問(wèn)題(轉(zhuǎn)行符和浮點(diǎn)數(shù)) - WCH藍(lán)牙應(yīng)用分享 - 博客園 (cnblogs.com)


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频