本帖最后由 ninuniu123 于 2013-7-29 12:57 编辑
想实现与电脑超级终端通信显示,但一直无连接通信,求大神指教
#include"stm8S105s6.h"
#include"stdio.h"
//时钟初始化
void CLK_Init(void)
{
CLK_CKDIVR = 0x00;
}
//UART2初始化
void UART2_Init(void)
{
UART2_CR3 = 0x00;
UART2_CR2 = 0x00;
UART2_CR1 = 0x00;
// 设置波特率
UART2_BRR2 = 0x0D; // 实际的波特率分频系数为00D0(208)
UART2_BRR1 = 0x00; //对应的波特率为2000000/208=9600
}
char putchar(char c)
{
while(!(UART2_SR&0x40));
UART2_DR = c;
while(!(UART2_SR&0x40));
return (c);
}
main()
{
unsigned char c;
CLK_Init();
UART2_Init();
UART2_CR2 = 0x0c;//收发使能
printf("显示正常");
while(1)
} |