3455|0

1

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

我的STM单片机软件仿真可以发送数据,为什么硬件数据发送不了啊? [复制链接]

具体程序如下:

///******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
//*******************************
//********************************
//***********************************
#include"stm32f10x_lib.h"


//*******************************]
//*********************************************
//********************************************
GPIO_InitTypeDef  GPIO_InitStructure;
NVIC_InitTypeDef  NVIC_InitStructure;
USART_InitTypeDef  USART_InitStructure;
USART_ClockInitTypeDef  USART_ClockInitStructure;
//****************************
//*****************************************
void GPIO_Configuration(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE); //¿ªÆôIO¿ÚDµÄµÆµÄ³õʼ»¯
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_SetBits(GPIOD,GPIO_Pin_2);
GPIO_Init(GPIOD,&GPIO_InitStructure);

//****************************************
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10|GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_SetBits(GPIOC,GPIO_Pin_10|GPIO_Pin_11);
GPIO_Init(GPIOC,&GPIO_InitStructure);
//*****************************************************
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE); //¿ªÆôUSARTµÄÊý¾ÝÊäÈë¡¢Êä³ö¿Ú
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2;
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_3;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
//GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
}
//********************************************
void USART_Configuration(void)
{

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);   //ÅäÖÃUSARTµÄ»ù±¾Êý¾Ý
USART_InitStructure.USART_BaudRate=9600;
USART_InitStructure.USART_WordLength=USART_WordLength_8b;
   USART_InitStructure.USART_StopBits=USART_StopBits_1;
   USART_InitStructure.USART_Parity=USART_Parity_No;
   USART_InitStructure.USART_Mode=USART_Mode_Tx|USART_Mode_Rx;
   USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
USART_Init(USART2,&USART_InitStructure);
//***********************************************
int main(void)
{
  
  int i;
  unsigned char TxBuf1[]="Welcome to my!";
  USART_ClearFlag(USART2,USART_FLAG_TC);
  GPIO_Configuration();
  USART_Configuration();
// NVIC_Configuration();
  while(1)
  {
  for(i=0;TxBuf1!='\0';i++)
  {
   USART_SendData(USART2,TxBuf1);
   GPIO_SetBits(GPIOC,GPIO_Pin_10);
   while(USART_GetFlagStatus(USART2,USART_FLAG_TC)==RESET);
   GPIO_ResetBits(GPIOC,GPIO_Pin_10);
  }
  i=0;
}  
}
软件仿真可以看到:

file:///C:/Users/Administrator/AppData/Roaming/Tencent/Users/805958628/QQ/WinTemp/RichOle/42BSERR~%7BVGBJ0UH12%7BMKRI.jpg
,但是在串口调试助手上看不到任何数据输出
此帖出自stm32/stm8论坛
点赞 关注
 

回复
举报
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
福禄克有奖直播:高精度测温赋能电子制造 报名中!
直播时间:2025年2月28日(周五)上午10:00
直播主题:高精度测温赋能电子制造
小伙伴们儿快来报名直播吧~好礼等你拿!

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表