找回密码
 立即注册
查看: 138|回复: 1

串口库函数求助

[复制链接]
  • 打卡等级:常住居民III
  • 打卡总天数:173
  • 最近打卡:2025-05-01 12:26:51
已绑定手机

17

主题

81

回帖

382

积分

中级会员

积分
382
发表于 2025-2-27 19:57:26 | 显示全部楼层 |阅读模式
  1. #include "STC8G_H_UART.h"
  2. #include <STC8G_H_Switch.h>
  3. #include        "STC8G_H_Delay.h"
  4. #include <Seg.h>
  5. #include <String.h>
  6. #include <Config.h>
  7. void System_Init()
  8. {
  9.         P_SW2 |= 0x80; //扩展外部XFR
  10.         //P_SW1 |= (0x01<<6); //P36,P37作为串口1
  11.   P3M0 = 0x00; P3M1 = 0x00;
  12.   P3PU = 0x03;
  13.         EA = 1;
  14. }
  15. void UART1_Init()
  16. {
  17.         COMx_InitDefine Comx_InitStructure;
  18.        
  19.         Comx_InitStructure.UART_Mode = UART_8bit_BRTx;
  20.         Comx_InitStructure.UART_BRT_Use = BRT_Timer1;
  21.         Comx_InitStructure.UART_BaudRate = 115200UL;
  22.         Comx_InitStructure.Morecommunicate = DISABLE;
  23.         Comx_InitStructure.UART_RxEnable = ENABLE;
  24.         Comx_InitStructure.BaudRateDouble = DISABLE;
  25.        
  26.         UART_Configuration(UART1,&Comx_InitStructure);
  27.         UART1_SW(UART1_SW_P30_P31);
  28. }
  29. void main()
  30. {
  31.         System_Init();
  32.         UART1_Init();
  33.        
  34.         while(1)
  35.         {
  36.                 TX1_write2buff(0x02);
  37.                 delay_ms(255);
  38.         }
  39. }
复制代码
请问这个库函数配置串口有问题吗,为什么不能正常发送数据
回复

使用道具 举报 送花

  • 打卡等级:偶尔看看III
  • 打卡总天数:54
  • 最近打卡:2025-05-01 09:07:55

717

主题

1万

回帖

1万

积分

管理员

积分
15611
发表于 2025-2-27 22:52:59 | 显示全部楼层
回复 支持 反对

使用道具 举报 送花

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2025-5-1 23:14 , Processed in 0.115478 second(s), 57 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表