[问题] 8051(w77e516)双uart设定问题

楼主: peter921 (PP)   2014-07-11 10:13:40
开发平台(Platform): (Ex: VC++, GCC, Linux, ...)
Keil C
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
问题(Question):
因为第一次用到双UART的ic
而在DATASHEET上写到
However the serial ports on the W77E516 can operate in different modes in
order to obtain timing similarity as well. Note that the serial port 0 can
use Timer 1 or 2 as baud rate generator, but the serial port 1 can only use
Timer 1 as baud rate generator.
想问说如何设定Serial 0用timer 2 而Serial 1使用timer1
喂入的资料(Input):
预期的正确结果(Expected Output):
错误结果(Wrong Output):
程式码(Code):(请善用置底文网页, 记得排版)
void InitialUart(void)
{
SCON = 0x50;
T2CON=0x30;
TH2 = 0xff;
TL2 = 0xc4;
RCAP2H = 0xff;
RCAP2L = 0xc4;
TR2 = 1;
TI = 1;
}
void InitialUart1()
{
SCON1 = 0xd0; //mode 3
PCON ^= 0x80;
TMOD |= 0x20;
TH1 = 251;
TR1 = 1;
TI1 = 1;
}
补充说明(Supplement):
在mcu一开始initial后,会先执行InitialUart()再执行InitialUart1()
而且的程式一开始只有用到uart0的部份
但是把uart1加进来之后,我外部lcd就不能显示原本正常的功能了
然后有把资料丢到uart1的sbuf1,我量io脚也没有输出
想问一下是哪边设定有错…
这个东西我卡快一个礼拜了QQ

Links booklink

Contact Us: admin [ a t ] ucptt.com