//uart configuartion
#define GPA0CON (*(volatile unsigned int *)0x11400000)
#define ULCON0 (*(volatile unsigned int *)0x13800000)
#define UCON0 (*(volatile unsigned int *)0x13800004)
#define UBRDIV0 (*(volatile unsigned int *)0x13800028)
#define UFRACVAL0 (*(volatile unsigned int *)0x1380002c)
#define UTXH0 (*(volatile unsigned int *)0x13800020)
#define UTRSTAT0 (*(volatile unsigned int *)0x13800010)
#define URXH0 (*(volatile unsigned int *)0x13800024)
void uart_init()
{
GPA0CON &= 0xffffff00;//设置引脚功能----uart模式
GPA0CON |= 0x22;
ULCON0 = 0x03;//设置uart通信格式,普通模式,无校验位,1位停止位,8位数据位
UCON0 = 0x05; //polling设置uart通信模式,中断或轮询模式
UBRDIV0 = 53;//波特率设置
UFRACVAL0 = 4;
}
void do_irq(void)
{
int irq_num;
}
void putc(char c)
{
while(1)
{
if (UTRSTAT0&0x02)//当其发送的buf为空时,跳出
break;
}
UTXH0 = c;//为发送寄存器装值
}
void delays1(int time)
{
int i = 0,j = 0;
while(time--)
{
for(i=0;i<5;i++)
for(j=0;j<514;j++);
}
}
int main(void)
{
uart_init();
while(1)
{
putc('a');
delays1(15);
}
return;
}
#define GPA0CON (*(volatile unsigned int *)0x11400000)
#define ULCON0 (*(volatile unsigned int *)0x13800000)
#define UCON0 (*(volatile unsigned int *)0x13800004)
#define UBRDIV0 (*(volatile unsigned int *)0x13800028)
#define UFRACVAL0 (*(volatile unsigned int *)0x1380002c)
#define UTXH0 (*(volatile unsigned int *)0x13800020)
#define UTRSTAT0 (*(volatile unsigned int *)0x13800010)
#define URXH0 (*(volatile unsigned int *)0x13800024)
void uart_init()
{
GPA0CON &= 0xffffff00;//设置引脚功能----uart模式
GPA0CON |= 0x22;
ULCON0 = 0x03;//设置uart通信格式,普通模式,无校验位,1位停止位,8位数据位
UCON0 = 0x05; //polling设置uart通信模式,中断或轮询模式
UBRDIV0 = 53;//波特率设置
UFRACVAL0 = 4;
}
void do_irq(void)
{
int irq_num;
}
void putc(char c)
{
while(1)
{
if (UTRSTAT0&0x02)//当其发送的buf为空时,跳出
break;
}
UTXH0 = c;//为发送寄存器装值
}
void delays1(int time)
{
int i = 0,j = 0;
while(time--)
{
for(i=0;i<5;i++)
for(j=0;j<514;j++);
}
}
int main(void)
{
uart_init();
while(1)
{
putc('a');
delays1(15);
}
return;
}