新手上路
- 积分
- 34
- 金钱
- 34
- 注册时间
- 2015-7-26
- 在线时间
- 0 小时
|
5金钱
#include "stm32f10x.h"
#include "sys.h"
#include "delay.h"
#include "stdio.h"
#define LED0 PAout(8)
#define LED1 PDout(2)
u8 table[]="Hello!";
void usart_init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
USART_InitTypeDef USART_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE); //开启GPIO时钟和复用功能
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE); //开启USART3时钟
USART_DeInit(USART3); //设置为缺省值
/*初始化GPIO   A.9设置*/
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_9;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStruct);
/*初始化GPIO   A.10设置*/
GPIO_InitStruct.GPIO_Pin=GPIO_Pin_10;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStruct);
GPIO_PinRemapConfig(GPIO_PartialRemap_USART3,ENABLE); //设置重映射
/*USART3初始化设置*/
USART_InitStruct.USART_BaudRate=9600;
USART_InitStruct.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
USART_InitStruct.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;
USART_InitStruct.USART_Parity=USART_Parity_No;
USART_InitStruct.USART_StopBits=USART_StopBits_1;
USART_InitStruct.USART_WordLength=USART_WordLength_8b;
USART_Init(USART3,&USART_InitStruct);
USART_Cmd(USART3,ENABLE); //使能USART3
}
int main(void)
{
u8 i;
delay_init();
usart_init();
for(i=0;i<6;i++)
{
USART_SendData(USART3,table);
delay_us(1000);
}
}
为什么在串口助手不会显示出来????
求大神指点 |
|