金牌会员
- 积分
- 2785
- 威望
- 534
- 贡献
- 1925
- 兑换币
- 20
- 注册时间
- 2009-10-12
- 在线时间
- 163 小时
|
- #include <hidef.h> /* common defines and macros */
- #include "derivative.h" /* derivative-specific definitions */
- void SetBusCLK_40M(void)
- {
- CLKSEL=0X00; //disengage PLL to system
- PLLCTL_PLLON=1; //turn on PLL
- SYNR =0x04; // 0xc0 |
- REFDV=0x01; //0x80 |
- POSTDIV=0x00; //pllclock=2*osc*(1+SYNR)/(1+REFDV)=80MHz;
- _asm(nop); //BUS CLOCK=40M
- _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; //允许SCI0发送⑺?查询方式
- SCI0BDH = 0x01; //注意:一定要先给高八位赋值 &&&我就错在这里了
- SCI0BDL = 0x04; //再给低8位赋值
- //SCI0CR1 = 0x00; //设置允许SCI,正常码输出,8位数据,无校验
- }
- void SCISend1(unsigned char o)
- {
- //判断ReStatusR的第SendTestBit位是否为1,是1可以发送
- while (1)
- if ((SCI0SR1 & (1<<7)) != 0)
- {
- SCI0DRL =o;
- break;
- }
- }
- void main(void) {
- /* put your own code here */
- SetBusCLK_40M();
- uart_init();
- EnableInterrupts;
- SCISend1('Z');
- for(;;) {
- _FEED_COP(); /* feeds the dog */
- } /* loop forever */
- /* please make sure that you never leave main */
- }
复制代码 |
|