关于 C语言的问题
eduqh 2009-12-06 06:46:42 大家好:
下面的这段代码是在ADS下面编译的
Uart_Printf("\nNow, Downloading [ADDRESS:%xh,TOTAL:%d]\n");
串口输出显示:Now, Downloading [ADDRESS:190h,TOTAL:400]
如果改成:
Uart_Printf("\nNow, Downloading [%xh,%d]\n");
串口输出显示:
Now, Downloading [190h,400]
请问大家里面的190h和400是怎么来的?
请高数指教。
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);
}
void Uart_SendString(char *pt)
{
while(*pt)
Uart_SendByte(*pt++);
}
void Uart_SendByte(int data) //若:void 则:Error :type disagreement for 'Uart_SendByte'
{
if(whichUart==0)
{
if(data=='\n')
{
while(!(rUTRSTAT0 & 0x2));
Delay(10); //because the slow response of hyper_terminal
WrUTXH0('\r');
}
while(!(rUTRSTAT0 & 0x2)); //Wait until THR is empty.
Delay(10);
WrUTXH0(data);
}
else if(whichUart==1)
{
if(data=='\n')
{
while(!(rUTRSTAT1 & 0x2));
Delay(10); //because the slow response of hyper_terminal
rUTXH1 = '\r';
}
while(!(rUTRSTAT1 & 0x2)); //Wait until THR is empty.
Delay(10);
rUTXH1 = data;
}
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;
}
}