esp8266 rtos3.0 printf和log输出串口选择

展开阅读全文

[stm32]无法使用printf 进行串口输出

10-30

main.crn[code=c]rn#include rnrnint main()rn System_Init();rn while(1)rn printf("a");rn delay_ms(1000);rn //USART_SendData(USART1,'a');rn rn// return 0;rnrn[/code]rnmain.hrn[code=c]rn#include rn#include rn#include rnrnrnvoid System_Init(void)rn SystemInit();rn Usart_Config();rnrn[/code]rnusart.hrn[code=c]rn#ifndef _USART_Hrn#define _USART_Hrn#include "stm32f10x.h"rn#include rnrnvoid Usart_Config(void);rnint fputc(int ch, FILE *f);rn//void USART1_printf(USART_TypeDef* USARTx, uint8_t *Data,...);rnrn#endifrn[/code]rnusart.crn[code=c]rn#include "usart.h"rnrnint fputc(int ch, FILE *f)rnrn USART_SendData(USART1, (uint8_t) ch);rn while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);rn return ch;rnrnvoid Usart_Config()rn GPIO_InitTypeDef GPIO_InitStructure;rn USART_InitTypeDef USART_InitStructure;rn rn RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_USART1/*|RCC_APB2Periph_AFIO*/,ENABLE);rn rn GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;rn rn GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;rn GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;//复用推挽式输出rn GPIO_Init(GPIOA,&GPIO_InitStructure);rn rn GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;rn GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;//模拟输入rn GPIO_Init(GPIOA,&GPIO_InitStructure);rn rn USART_InitStructure.USART_BaudRate=9600;/*设置波特率*/rn USART_InitStructure.USART_WordLength=USART_WordLength_8b;/*设置传送数据长度*/rn USART_InitStructure.USART_StopBits=USART_StopBits_1;/*设置停止位的长度*/rn USART_InitStructure.USART_Parity=USART_Parity_No;/*设置是否需要检验*/rn USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;/*设置硬件流*/rn USART_InitStructure.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;/*设置串口模式*/rn rn USART_Init(USART1,&USART_InitStructure);rn USART_Cmd(USART1,ENABLE);rnrn rnrn[/code]rnrn以上是代码 进入模拟后 会卡在 POP r3,pc这一行rnrnUSART_SendData(USART1,'a'); 如果用这个函数输出 就正常 可以正常的发送 但是用printf 就不行了,都进入不到while(1)里面 论坛

没有更多推荐了,返回首页