|
首先感谢你的答复!
不是学硬件的。不知道用示波器怎么测试?
改写的bootloader使用的波特率为115200,终端也设置为这个数。在bootloader stage1没用到串口,只是对IO口进行了初始化设置,对串口的初始化在stage2中进行,代码如下:
static int s3c2410_serial_init(serial_baud_t baud)
{
u32 divisor;
//UBRDIVn = (int)(PCLK / (bps x 16) ) –1
//or
//UBRDIVn = (int)(UCLK / (bps x 16) ) –1
//usually,PCLK=FCLK/4=MCLK(202.8MHz)/4,UCLK为USB所用频率
/* get correct divisor */
switch(baud) {
case baud_1200:
divisor = 2639;
break;
case baud_9600:
divisor = 329;
break;
case baud_19200:
divisor = 164;
break;
case baud_38400:
divisor = 81;
break;
case baud_57600:
divisor = 54;
break;
case baud_115200:
divisor = 26;
break;
default:
return -ERANGE;
}
s3c2410_serial_flush_output();
rUFCON0 = 0x0; //FIFO Control Register,disable FIFO
rULCON0 = 0x03; //data bits number,设置数据位8,无奇偶校验位,1位停止位
rUCON0 = 0x05; //Transmit/Receive mode:Interrupt,polling or DMA.Here,Interrupt or polling.Pulse Interrupt.Select PCLK as the UART baud rate.
rUBRDIV0 = divisor;//设置波特率
rUFCON1 = 0x0;
rULCON1 = 0x03;
rUCON1 = 0x05;
rUBRDIV1 = divisor;
for(divisor=0; divisor<100; divisor++);
return 0;
}
这里:baud_57600、baud_115200为枚举类型中的元素。
不知道这样做有什么问题,请高手们指点! |
|