跨届大侠
北京龙邱智能科技有限公司
- 积分
- 10332
- 威望
- 2905
- 贡献
- 6151
- 兑换币
- 4515
- 注册时间
- 2008-6-7
- 在线时间
- 638 小时
|
只是发的快慢的问题,你的这个串口设置好像很简单,没有波特率矫正的部分,所以,可能会出问题的。下面是K60F系列的初始化过程,参考下(程序里面锁相环用的是400M,总线是200M,UART0/1的波特率是由总线决定的)
/* Calculate baud settings */
uint32 sbr=0, brfa=0,baud=115200,busclk_k=200000;
// 超频
pllinit400M();
/* Enable the clock to the selected UART */
SIM_SCGC4 |= SIM_SCGC4_UART0_MASK;
/* Enable the UART0_TXD function on PTD6 */
PORTD_PCR6 = PORT_PCR_MUX(0x3); // UART is alt3 function for this pin
/* Enable the UART0_RXD function on PTD7 */
PORTD_PCR7 = PORT_PCR_MUX(0x3); // UART is alt3 function for this pin
//共两步骤:超频第2步,设置串口波特率,系统主频跟上面的必须一致才行
//UART baud rate = UART module clock / (16 × (SBR[SBR] +BRFD))
//UART0 and UART1 modules operate from the core/system clock
sbr = (unsigned short)((busclk_k*1000)/(baud*16));
//参考龙邱核心板\01_芯片数据表\K60P144M150SF3RM.pdf--P.1773,占13bit
UART0_BDH = (unsigned char)((sbr & 0x1F00) >> 8);
UART0_BDL = (unsigned char)( sbr & 0x00FF);
/* Determine if a fractional divider is needed to get closer to the baud rate */
brfa = (((busclk_k*2000)/baud) - (sbr * 32));
//brfa =0;
UART0_C4 = (unsigned char)(brfa & 0x001F);
/* Configure the UART for 8-bit mode, no parity */
UART0_C1 = 0;
/* Enable receiver and transmitter */
UART0_C2 |= (UART_C2_TE_MASK | UART_C2_RE_MASK ); |
|