[mw_shl_code=c,true]#include "sys.h"
#include "delay.h"
#include "stm32f10x_flash.h"
void My_USART1_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode= GPIO_Mode_IN_FLOATING;;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate= 9600;
USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None ;
USART_InitStructure.USART_Mode= USART_Mode_Tx|USART_Mode_Rx;
USART_InitStructure.USART_Parity=USART_Parity_No;
USART_InitStructure.USART_StopBits=USART_StopBits_1;
USART_InitStructure.USART_WordLength= USART_WordLength_8b;
USART_Init(USART1,&USART_InitStructure);
USART_Cmd(USART1,ENABLE);
}
int main (void)
{
u8 i;
char *str;
str="abcdefg";
My_USART1_Init();
while(*str)
{ USART_SendData(USART1,*str);
while(USART_GetFlagStatus(USART1, USART_FLAG_TC)==RESET);
delay_ms(200);
str++;
}
}[/mw_shl_code]
请问:为什么在串口助手上无法显示?我试过通过将字符串通过串口助手发送给STM32然后再使stm32将数据发送出来,串口助手就可以正常显示!!这是为什么??这个问题困扰好几天了 求教!! |