本帖最后由 lsy3500 于 2017-1-5 14:02 编辑
各位大大好,有个问题,我用的是stm32f103c8t6,从网上下载了一个 stm32f103c8t6 使用 USART1 串口打印测试程序(重定向printf函数),检查参数设置无误后编译通过,下载到板子上以后,串口调试助手却怎么也没反应,难道是硬件的问题?只是硬件问题一般比较少见,所以先跪求各位大大帮我看看软件是不是还有什么问题。这是我下载的部分主要程序,附件是源代码,跪求各位大大帮我看看非常感谢:
[mw_shl_code=c,true]int main(void)
{
/* 系统时钟设置为 72M */
SystemInit();
/* USART1 config 115200 8-N-1 */
USART1_Config();
printf("
*********This is a printf demo********
");
printf("
* This is a USART1_printf demo *
");
USART1_printf(USART1, "
* -------------------- *
");
USART1_printf(USART1, "
* STM32F103C8T6 Development Board *
");
USART1_printf(USART1, "
* ----------------------------------- *
");
USART1_printf(USART1, "
---------------------------------------
");
while (1)
{
;
}
}[/mw_shl_code]
[mw_shl_code=c,true]void USART1_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/* config USART1 clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);
/* USART1 GPIO config */
/* Configure USART1 Tx (PA.09) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART1 Rx (PA.10) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //¸¡¿Õêäèë
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* USART1 mode config */
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE);
[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>