试了很多程序都不行,贴个最简单的吧
# include "linux/option.h"
# include "linux/2440addr.h"
# include "linux/2440lib.h"
# include "linux/2440slib.h"
# include "linux/s3c2440.h"
# include "linux/profile.h"
# include "linux/mmu.h"
void Uart_init()
{
rULCON0 = 0x03;
rUCON0 = 0x05;
rUFCON0 = 0x00;
rUMCON0 = 0x00;
rUBRDIV0 = 0x144;
//rGPHCON = rGPHCON & (~(0xffff)) ;
rGPHCON = rGPHCON | (0xaaa0) ;
rULCON1 = 0x03;
rUCON1 = 0x05;
rUFCON1 = 0x00;
rUMCON1 = 0x00;
rUBRDIV1 = 0x144;
}
void Uart_send_bit(unsigned char c, int n)
{
switch (n)
{
case 0 :
while(!(rUTRSTAT0 & 0x2)); //等待并判断发送缓存是否为空
rUTXH0 = c;
break;
case 1 :
while(!(rUTRSTAT1 & 0x2)); //等待并判断发送缓存是否为空
rUTXH1 = c;
break;
}
}
unsigned char Uart_get_bit(int n)
{
switch (n)
{
case 0 :
while(!(rUTRSTAT0 & 0x1)); //等待并判断接收缓存是否准备好
return rURXH0; //接收一个字节数据
break;
case 1 :
while(!(rUTRSTAT1 & 0x1)); //等待并判断接收缓存是否准备好
return rURXH1; //接收一个字节数据
break;
}
}
int main()
{
unsigned char i;
Uart_init();
//初始化串口
while(1)
{
for(i=0; i<100; i++)
{
Uart_send_bit(i,0);
}
}
return 0;
}
都是在寄存器初始化的时候FAULT的