本帖最后由 zuo2016 于 2016-8-16 15:12 编辑
我用STM8S207C8T6在串口1收发都好好的程序,改到串口3为啥只能收,不能发了
void uart3_init(){
UART3_BRR2 = 0x01;
UART3_BRR1 = 0x34;//设置波特率为19200
UART3_CR1 = 0x00; //设置接收数据位为8位
UART3_CR3 = 0x00; //设置停止位为1位
UART3_CR4 = 0x00;
UART3_CR6 = 0x00;
UART3_CR2 =0x2c; //使能发送、接收
}
void clk_init(){
CLK_CKDIVR = 0x00;//cpu 采用内部16/1=16M RC时钟
}
main()
{
clk_init();
uart3_init();
send_buf1 = 0;
_asm("rim");
while (1){
while(!(UART3_SR &0x80));
UART3_DR = send_buf1;
while((UART3_SR &0x40)==0);
delay(1000);
send_buf1++;
}
} |