main.c

来自「根据freescale XXDZ60的多用途时钟发生器的设置原理」· C语言 代码 · 共 55 行

C
55
字号
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */


 void PeriphInit(void)
{
										
  // Clear COP Watchdog timeout
  SOPT1 = 0x00;
  
  // Select FBE MCG mode (IREFS=0, CLKS=10)
  MCGC1 = 0xB8;
  // LP=0 and selects external high frequency crystal clock  		                
  MCGC2 = 0x36;
  // PLLS=0
  MCGC3 = 0x00;
  // Wait until the initialization cycle of the external crystal clock is completed 
  while(!(MCGSC&0x02))
    {
  
  // Set TJA1040 CAN transceiver in normal mode operation (STB LOW) 
  PTDD = 0x00;
  PTDDD = 0x55;   
    }
  
 }

void main(void) {
  unsigned int wCount;
  
  EnableInterrupts; /* enable interrupts */
  /* include your code here */
 /// PTDDD = 0xFF;
  ///PTDD = 0x55;

  PeriphInit();
 
  for(;;) 
  {
    for (wCount = 0; wCount < 0xfff0; wCount++) 
    { }     
      if (PTDD == 0x55) 
         {
           PTDD = 0xA6;
         }
      else 
        {
          PTDD = 0x55;
        }
     
    __RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}

⌨️ 快捷键说明

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