|
int8 UART1_Init(uint32 baud,uint8 datab,uint8 stopb,uint8 parity)
{
uint32 tmp;
PINSEL0 = (PINSEL0 & (~0x0F0000)) | 0x050000; // (先清零,再赋值) P0.8 、.P0.9
// PINSEL2 = (PINSEL2 & (~0x08)); //P1.24 为 GPIO
IO1DIR |= (1<<24); //P1.24为输出口
// IRQEnable();
if ((baud==0) || (baud>115200)) return 0;
if ((datab<5) || (datab>8)) return 0;
if ((stopb==0)|| (stopb>2)) return 0;
if (parity>4) return 0;
U1LCR = 0x80; // Enable access to Divisor Latches
tmp = (Fpclk >> 4) / baud;
U1DLM = tmp >> 8;
U1DLL = tmp & 0xFF;
tmp = datab - 5; // 设置字长
if (stopb==2) tmp |= 0x04; // 设置停止位
if (parity!=0) // 设置奇偶校验位
{
parity--;
tmp |= 0x08;
}
tmp |= parity << 4;
U1LCR = tmp;
U1FCR = 0x81; //使能FIFO,并设置触发点为8字节
U1IER = 0x01; //允许RBR中断,即接收中断
rcv_new1 = 0;
Uart1SemPtr = OSSemCreate(1);
return 1;
}
执行 这个函数后 ,uc/os2系统死掉。
什么原因?
|
|