Crystalline 发表于 2025-2-27 19:57:26

串口库函数求助


#include "STC8G_H_UART.h"
#include <STC8G_H_Switch.h>
#include        "STC8G_H_Delay.h"
#include <Seg.h>
#include <String.h>
#include <Config.h>


void System_Init()
{
        P_SW2 |= 0x80; //扩展外部XFR
        //P_SW1 |= (0x01<<6); //P36,P37作为串口1
P3M0 = 0x00; P3M1 = 0x00;
P3PU = 0x03;


        EA = 1;
}

void UART1_Init()
{
        COMx_InitDefine Comx_InitStructure;
       
        Comx_InitStructure.UART_Mode = UART_8bit_BRTx;
        Comx_InitStructure.UART_BRT_Use = BRT_Timer1;
        Comx_InitStructure.UART_BaudRate = 115200UL;
        Comx_InitStructure.Morecommunicate = DISABLE;
        Comx_InitStructure.UART_RxEnable = ENABLE;
        Comx_InitStructure.BaudRateDouble = DISABLE;
       
        UART_Configuration(UART1,&Comx_InitStructure);
        UART1_SW(UART1_SW_P30_P31);
}
void main()
{
        System_Init();
        UART1_Init();
       

        while(1)
        {
                TX1_write2buff(0x02);
                delay_ms(255);
        }
}
请问这个库函数配置串口有问题吗,为什么不能正常发送数据

神农鼎 发表于 2025-2-27 22:52:59

可以先看下如下的视频讲解


第7集 UART串口的使用-32G库函数-STC单片机教学视频 国芯技术交流网站 - AI32位8051交流社区



视频讲解:串口绘图功能、串口助手高级应用、 8系列库函数|串口库函数功能介绍 - 串行口,DMA支持的4组串口,RS232,RS485,Modbus, CRC16 国芯技术交流网站 - AI32位8051交流社区
页: [1]
查看完整版本: 串口库函数求助