STM8S UART3 的数据传输问题。在串口调试软件里,发送的数据单片机不能接收到,但能接收到单片机的数据。
#include"stm8s.h"#include"stm8s_uart3.h"#include"stm8s_clk.h"voidCLK_Config(void){CLK...
#include "stm8s.h"
#include "stm8s_uart3.h"
#include "stm8s_clk.h"
void CLK_Config(void)
{
CLK_DeInit();
//CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV2);//change the default value DIV8 into DIV2
}
void UART3_Config(void)
{
UART3_DeInit();
UART3_Init((u32)19200,UART3_WORDLENGTH_8D,UART3_STOPBITS_1,UART3_PARITY_NO,UART3_MODE_TXRX_ENABLE);
}
int delay(u16 time)
{
for(time;time>0;time--);
}
main()
{
static u8 data;
//data=0X03;
CLK_Config();
UART3_Config();
while (1)
{
data=UART3_ReceiveData8();
delay(1000);
//data=1;
UART3_SendData8(data);
}
} 展开
#include "stm8s_uart3.h"
#include "stm8s_clk.h"
void CLK_Config(void)
{
CLK_DeInit();
//CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV2);//change the default value DIV8 into DIV2
}
void UART3_Config(void)
{
UART3_DeInit();
UART3_Init((u32)19200,UART3_WORDLENGTH_8D,UART3_STOPBITS_1,UART3_PARITY_NO,UART3_MODE_TXRX_ENABLE);
}
int delay(u16 time)
{
for(time;time>0;time--);
}
main()
{
static u8 data;
//data=0X03;
CLK_Config();
UART3_Config();
while (1)
{
data=UART3_ReceiveData8();
delay(1000);
//data=1;
UART3_SendData8(data);
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询