小菜鸟求助,串口发送程序编译通过,在板子上没反应

[复制链接]
 楼主| yisibugua16 发表于 2012-3-2 14:02 | 显示全部楼层 |阅读模式
#include "stm32f10x.h"
#include <stdio.h>

#ifdef __GNUC__
  #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
  #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif

void Delay(vu32 count)
{
for(;count!=0;count--);
}

int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
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);

  printf("\n\r串口1发送实验程序\n");
   while (1)
{
   printf("\n\r串口1发送实验程序\n");
   Delay(0x3FFFFF);
   printf("\n\r串口1发送实验程序\n");
      
}      
}

PUTCHAR_PROTOTYPE
{
    USART_SendData(USART1, (uint8_t) ch);
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
{}
return ch;
}


#ifdef  USE_FULL_ASSERT
void assert_failed(uint8_t* file, uint32_t line)
{
    while (1)
  {
  }
}
#endif
 楼主| yisibugua16 发表于 2012-3-2 15:39 | 显示全部楼层
:'(有人说下没
wyx447166939 发表于 2012-3-2 20:06 | 显示全部楼层
不懂看下终端设置对了没
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

8

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部