|
#define LOCKCON0 (*(volatile unsigned*)0x4C000000)
#define LOCKCON1 (*(volatile unsigned*)0x4C000004)
#define MPLLCON (*(volatile unsigned*)0x4C000008)
#define EPLLCON (*(volatile unsigned*)0x4C000010)
#define CLKDIV0 (*(volatile unsigned*)0x4C000024)
#define EPLLCON_K (*(volatile unsigned*)0x4C00001C)
#define CLKSRC (*(volatile unsigned*)0x4C000020)
#define GPHCON (*(volatile unsigned *)0x56000070)
#define ULCON0 (*(volatile unsigned *)0X50000000) //uart0线控制寄存器
#define UCON0 (*(volatile unsigned *)0X50000004)
#define UFCON0 (*(volatile unsigned *)0X50000008)
#define UMCON0 (*(volatile unsigned *)0X5000000c)
#define UTRSTAT0 (*(volatile unsigned *)0X50000010)
#define UERSTAT0 (*(volatile unsigned *)0X50000014)
#define UFSTAT0 (*(volatile unsigned *)0X50000018)
#define UMSTAT0 (*(volatile unsigned *)0X5000001c)
#define UTXH0 (*(volatile unsigned *)0X50000020)
#define URXH0 (*(volatile unsigned *)0X50000024)
#define UBRDIV0 (*(volatile unsigned *)0X50000028)
#define UDIVSLOT0 (*(volatile unsigned *)0X5000002C)
int main(void)
{
LOCKCON0=3600;
LOCKCON1=3600;
CLKDIV0=(1<<9)|(2<<4)|(1<<3)|(1<<2)|(0<<0);
MPLLCON=(0<<24)|(400<<14)|(3<<5)|(1<<0);
EPLLCON=(0<<25)|(0<<24)|(32<<16)|(1<<8)|(2<<0);
EPLLCON_K=0x000;
CLKSRC=(3<<7)|(1<<6)|(1<<4);
char buf;
char buf1;
buf1='q';
GPHCON &= ~((3<<0)|(3<<2));
GPHCON|=(2<<0)|(2<<2);
ULCON0=0X03; //1位起始位 八位数据位
UCON0=0X5; //串行时钟Pclk 查询方式
UFCON0=0X01;
UMCON0=0x00;
UBRDIV0=35;
UDIVSLOT0=1; //波特率115200
while(1)
{
//UTXH0=buf1;
if (UTRSTAT0&0X01)
{
buf=URXH0;
while(!(UTRSTAT0&0x02));
UTXH0=buf;
}
}
}
|
|