本帖最后由 luofeng2g 于 2014-10-8 10:56 编辑
FSL_TICS_ZJJ 发表于 2014-10-8 10:42 
楼主波特率配置的是多少?
把你的代码工程上传看看。
波特率是按自带的uart.c里面配置的!
sysint.c 中 else if (TERM_PORT_NUM == 1)
uart_init (UART1_BASE_PTR, periph_clk_khz, TERMINAL_BAUD);
tower.h中 #define TERMINAL_BAUD 19200
使用的是内部时钟;
void uart_init (UART_MemMapPtr uartch, int sysclk, int baud)
{
register uint16 sbr;
uint8 temp;
if (uartch == UART1_BASE_PTR)
SIM_SCGC4 |= SIM_SCGC4_UART1_MASK;
else
SIM_SCGC4 |= SIM_SCGC4_UART2_MASK;
/* Make sure that the transmitter and receiver are disabled while we
* change settings.
*/
UART_C2_REG(uartch) &= ~(UART_C2_TE_MASK
| UART_C2_RE_MASK );
/* Configure the uart for 8-bit mode, no parity */
UART_C1_REG(uartch) = 0; /* We need all default settings, so entire register is cleared */
/* Calculate baud settings */
sbr = (uint16)((sysclk*1000)/(baud * 16));
/* Save off the current value of the uartx_BDH except for the SBR field */
temp = UART_BDH_REG(uartch) & ~(UART_BDH_SBR(0x1F));
UART_BDH_REG(uartch) = temp | UART_BDH_SBR(((sbr & 0x1F00) >> 8));
UART_BDL_REG(uartch) = (uint8)(sbr & UART_BDL_SBR_MASK);
/* Enable receiver and transmitter */
UART_C2_REG(uartch) |= (UART_C2_TE_MASK
| UART_C2_RE_MASK );
}
/********************************************************************/
/*
* Wait for a character to be received on the specified uart
*
* Parameters:
* channel uart channel to read from
*
* Return Values:
* the received character
*/
char uart_getchar (UART_MemMapPtr channel)
{
/* Wait until character has been received */
while (!(UART_S1_REG(channel) & UART_S1_RDRF_MASK));
/* Return the 8-bit data from the receiver */
return UART_D_REG(channel);
}
都是自带的!是不是配置为内部时钟有什么问题?
|