高级会员
- 积分
- 787
- 威望
- 398
- 贡献
- 239
- 兑换币
- 24
- 注册时间
- 2009-12-16
- 在线时间
- 75 小时
|
- #include <hidef.h> /* common defines and macros */
- #include "derivative.h" /* derivative-specific definitions */
- void SetBusCLK_80M(void)
- {
- CLKSEL=0X00; //disengage PLL to system
- PLLCTL_PLLON=1; //turn on PLL
- SYNR =0xc0 | 0x09;
- REFDV=0x80 | 0x01;
- POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=160MHz;
- _asm(nop); //BUS CLOCK=80M
- _asm(nop);
- while(!(CRGFLG_LOCK==1)); //when pll is steady ,then use it;
- CLKSEL_PLLSEL =1; //engage PLL to system;
- }
- void uart_init (void)
- {
- SCI0CR2=0x0c;
- SCI0BDH=0x02;
- SCI0BDL=0X09;
- }
- void uart_putchar (unsigned char ch)
- {
- while (!(SCI0SR1&0x80))
- {
- }
- SCI0DRL=ch;
- }
- void SciSendStr(unsigned char *buf)
- {
- unsigned char *p;
- p=buf;
- while(*p!='\0')
- {
- uart_putchar(*p++);
- }
- }
- void main(void) {
- /* put your own code here */
- SetBusCLK_80M();
- uart_init();
- SciSendStr("TianTian");
- EnableInterrupts;
- for(;;) {
- _FEED_COP(); /* feeds the dog */
- } /* loop forever */
- /* please make sure that you never leave main */
- }
复制代码 |
|