岁纳京子 发表于 2016-5-1 22:11:40

串口发送字节失败

初始化程序什么的都调用了,却没有发送,走仿真发现会一直停在发送数据为空的判断上

#include "uart1.h"

void G_chuankouchushihua(void)
{
UART1_DeInit();
UART1_Init((u32)9600, UART1_WORDLENGTH_8D, UART1_STOPBITS_1,\
    UART1_PARITY_NO, UART1_SYNCMODE_CLOCK_DISABLE, UART1_MODE_TXRX_ENABLE);
UART1_Cmd(ENABLE);
}

void G_chuankoufazijie(unsigned char byte)
{
UART1_SendData8(byte);
while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET);//发送数据为空

}



#include "stm8s.h"
#include "stm8s_clk.h"
#include "uart1.h"

void G_chushihua(void)
{
CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);
void G_chuankouchushihua(void);
}

static void delay (int cnt)
{
while (cnt--);
}

int main(void)
{
G_chushihua();
while (1)
{
    delay(10000);
    delay(10000);
    delay(10000);
    G_chuankoufazijie('a');
    G_chuankoufazijie('b');
    G_chuankoufazijie('c');
}
}


岁纳京子 发表于 2016-5-2 15:33:20

好失败的感觉,居然是初始化本来想调用,却写成了声明。太傻了,居然1天都没看出来
页: [1]
查看完整版本: 串口发送字节失败