|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
用的是三星的测试代码,一直发送不出去,axd调试时发现无法给发送寄存器赋值,始终是0.另外,非fifo的发送方式应该不用中断的吧?调了快两天了,郁闷,望各位高手帮忙看看,指点指点.代码如下:
void Main(void)
{
unsigned char data[6] = {0, 1, 2, 3, 4, 5};
/* 配置系统时钟 */
ChangeClockDivider(1,1); // 1:2:4
ChangeMPllValue(0xa1,0x3,0x1); // FCLK=202.8MHz
/* 初始化端口 */
Port_Init();
/* 初始化串口 */
Uart_Init(0,115200);
Uart_Select(1); //用串口1
/* 打印提示信息 */
PRINTF("abcdedg");//已define printf uart_printf
}
/********************************************************************
// Function name : Uart_Printf
// Description : 串口打印函数
// Return type : void
// Argument : char *fmt
// Argument : ...
*********************************************************************/
void Uart_Printf(char *fmt,...)
{
va_list ap;
char string[256];
va_start(ap,fmt);
vsprintf(string,fmt,ap);
Uart_SendString(string);
va_end(ap);
}
/********************************************************************
// Function name : Uart_SendString x
// Description : 通过串口发送字符串
// Return type : void
// Argument : char *pt:字符串指针
*********************************************************************/
void Uart_SendString(char *pt)
{
while(*pt)
Uart_SendByte(*pt++);
}
void Uart_SendByte(int data)
{
if(whichUart==0)
{
if(data=='\n')
{
while(!(rUTRSTAT0 & 0x2));
// Delay(10);
WrUTXH0('\r');
}
while(!(rUTRSTAT0 & 0x2));
// Delay(10);
WrUTXH0(data);
}
else if(whichUart==1)
{
if(data=='\n')//data 到此处后变量窗口显示,variable not used
//(optimization),值没了
{
while(!(rUTRSTAT1 & 0x2));
// Delay(10);
rUTXH1 = '\r';
}
while(!(rUTRSTAT1 & 0x2)); //Wait until THR is empty.
// Delay(10);
rUTXH1 = data;//rUTH1的值始终是0,即使赋常量也不行,还是0
}
else if(whichUart==2)
{
if(data=='\n')
{
while(!(rUTRSTAT2 & 0x2));
// Delay(10); //because the slow response of hyper_terminal
rUTXH2 = '\r';
}
while(!(rUTRSTAT2 & 0x2)); //Wait until THR is empty.
Delay(10);
rUTXH2 = data;
}
} |
|