- UID
- 342595
- 性别
- 男
|
为了测试串口,我利用13213内部时钟写了一个串口发送程序(时钟相关寄存器的配置完全按照1321xRM中“Example #3: No External Crystal Connection, 5.4 MHz Bus
Frequency”设置,除了将参照smac中将icgc1中的OSCSTEN置为1),但是无法通过13213开发板和pc机的串口助手无法通信,请高手们现身给点建议,谢谢!代码如下:
ICGC1 = 0x2c;
ICGC2 = 0x31;
SCIInitGeneric(5400000, 38400, NO2_SCI_PORT);
SCIStartTransmit(0x7E);
void SCIInitGeneric(UINT32 u32BusClock, UINT32 u32BaudRate, UINT8 u8ComNumber) {
UINT16 u16Sbr = IDLE;
SCICounter = 0;
gu8SCIDataFlag = IDLE;
u16Sbr = (UINT16) ((u32BusClock) / (u32BaudRate * 16));
switch (u8ComNumber) {
case NO1_SCI_PORT:
SCI1BDL = (UINT8) u16Sbr;
u16Sbr = u16Sbr >> 8;
SCI1BDH = (UINT8) u16Sbr;
SCI1C2 = INIT_SCI2C2; // INIT_SCI2C2 = 0b00101100
break;
case NO2_SCI_PORT:
SCI2BDL = (UINT8) u16Sbr;
u16Sbr = u16Sbr >> 8;
SCI2BDH = (UINT8) u16Sbr;
SCI2C2 = INIT_SCI2C2;
break;
default:
SCI1BDL = (UINT8) u16Sbr;
u16Sbr = u16Sbr >> 8;
SCI1BDH = (UINT8) u16Sbr;
SCI1C2 = INIT_SCI2C2;
break;
}
}
void SCIStartTransmit(UINT8 cData)
{
while (!SCI2S1_TDRE); /* ensure Tx data buffer empty */
SCI2D = cData; /* load data to SCI2 register */
while (!SCI2S1_TC); /* wait for Tx complete */
LED4 = 0;
}
|
|