⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 根据freescale XXDZ60的多用途时钟发生器的设置原理
💻 C
字号:
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */



void main(void) {

  unsigned int wCount,wCount1,wCount2;

  EnableInterrupts; /* enable interrupts */
  /* include your code here */

   PTDDD = 0xFF;
   PTDD = 0x55;
      PTADD = 0xFF;
       PTAD = 0x00;
       
   
   //PEE(PLL engaged external)模式总线频率fbus=[(fext/R)*M]/B =4/4*40/2=20
   
                                      
    MCGC2=0x76;                  // BDIV=01,/2^2=/4
   
    while(MCGSC_OSCINIT!=1);     // 如果MCGSC_OSCINIT不为1则等待
      
    MCGC1=0xA0;                     // RDIV=100,/2^4=/16
    
    while((MCGSC_IREFST!=0)||(MCGSC_CLKST!=0b10)); 
       
         MCGC2_LP=1;                 
         MCGC1=0x90;                // RDIV=010,/2^2=/4   ,PEE模式下,fext/R必须=1~2M
         MCGC3=0x4A;                // M=1010,*40
         MCGC2_LP=0;                //
        while((MCGSC_PLLST!=1)||(MCGSC_LOCK!=1)); 

                     
           MCGC1=0x10;               // RDIV=010,/2^2=/4
           while(MCGSC_CLKST!=0b11) 
           {
           
           }      
    
    
       
  for(;;) {
                     
               for (wCount = 0; wCount < 0xfff3; wCount++)       //牺牲CPU时序,循环延时
                      { }      
               for (wCount1 = 0; wCount1 < 0xfff4; wCount1++) 
                      { } 
    
               for (wCount2 = 0; wCount2 < 0xfff2; wCount2++)  
                      { }       
               if (PTDD == 0x55)                                 //赋不同的值使相应的LED闪烁
                {
                  PTDD = 0x00;
                  PTAD=0x55;
                }
               else 
               {
                  PTDD = 0x55;
                  PTAD=0x00;
               }
                           
           
    __RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -