https://static.assets-stash.eet-china.com/album/old-resources/2009/5/18/98c0ac1c-53a6-4e28-8702-8b61151a3ae2.rar
1.系统时间设置
ChangeMPllValue(0x5c, 0x01, 0x02); //FCLK改成200Mhz
ChangeClockDivider(12, 12); //1:2:4
2.串口初始化
Port_Init(); //初始化Port,其中有Uart[0-2]
3.接收函数
void Uart_GetString(char *string)
void Uart_SendByte(int data)
4.发送函数
void Uart_Printf(char *fmt,...)
void Uart_SendString(char *pt)
void Uart_SendByte(int data)
5.延时函数
void Delay(int time)
6.测试
#include "2440addr.h"
#include "2440lib.h"
#include "def.h"
U32 FCLK, HCLK, PCLK;
void Main()
{
char buffer[256];
ChangeMPllValue(0x5c, 0x01, 0x02); //FCLK改成200Mhz
ChangeClockDivider(12, 12); //1:2:4
FCLK = 200 * 1000 * 1000;
HCLK = FCLK/2; PCLK = HCLK/2;
Port_Init(); //初始化Port,其中有Uart[0-2]
Uart_Init(0, 115200); //串口初始化
Uart_Select(1);
Delay(0);
Uart_Printf("\nUART Console test.\n");
while(1) {
Uart_Printf("Please,press enter later input string\n");
Uart_GetString(buffer);
Uart_Printf("you input string: %s\r\n", buffer);
}
}
学自《ARM Linux》入门与实践,其中delay的校正原理讲得还不错,第二次看终于有点感悟。
关闭
站长推荐
/3
用户1354166 2009-7-5 17:46
yannzi 2009-5-19 20:33
用户201423 2009-5-18 18:59