- 积分
- 31
贡献56
飞刀0 FD
注册时间2013-3-8
在线时间6 小时

扫一扫,手机访问本帖 
|
本帖最后由 573370486 于 2013-4-2 09:55 编辑
其实核 心问题是:整型数据,如何转成char数组,然后再给到寄存器显示出来。
全程提供的很啰嗦。完全没必要那样做,有没有供新手用的例程?很纠结这么复杂。- //If you don't use vsprintf(), the code size is reduced very much.
- void Uart_Printf(S8 *fmt,...)
- {
- va_list ap;
- S8 str[255];
- va_start(ap,fmt);
- vsprintf(str,fmt,ap);
- Uart_SendString(str);
- va_end(ap);
- }
复制代码- void Uart_SendByte(int data)
- {
- if(data=='\n')
- {
- while(!(rUTRSTAT0 & 0x2));
- // Delay(1); //because the slow response of hyper_terminal
- WrUTXH0('\r');
- }
- while(!(rUTRSTAT0 & 0x2)); //Wait until THR is empty.
- // Delay(1);
- WrUTXH0(data);
- }
复制代码 int 是32位。怎么通过UTXH0就送出来了呢?UTXH0可是8位的啊。 |
|