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

📄 hardwareinit.c

📁 飞思卡尔智能车用的决策程序,这是由参加过的研究生提供的例子
💻 C
字号:
#include <hidef.h>      /* common defines and macros */
#include <mc9s12dg128.h>     /* derivative information */


#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"

void HardwareInit(void) {
  DisableInterrupts;
  
  // CLOCK Initialize
  REFDV=1;
  SYNR=2;
  asm{
    BRCLR CRGFLG,#$08,*
  }
  CLKSEL=0x80;
  
  // SCI Initialize
  SCI0CR2=0x0C;
  SCI0BD=0x009C;
  
  // PORT Initialize
  DDRB=0;
  DDRH=0;
  DDRK=0xFF;
  PORTK=0x08;
  
  // PWM Initialize
  PWMCTL=0x40;
  PWMPRCLK=0x33;
  PWMCLK=0x00;
  PWMPOL=0xFF;
  PWMPER0=0x64;
  PWMPER1=0x64;
  PWMDTY0=0x00;
  PWMDTY1=0x00;
  PWMPER4=0xEA;
  PWMPER5=0x60;
  PWMDTY45=4500;
  PWME=0x33;
  
  // ECT Initialize
  TIOS=0x0F;
  TIE=0;
  TSCR2=3;
  TCTL3=0x40;
  TSCR1=0x81;
  
  // ADT Initialize
  ATD0CTL2=0x00;
  ATD0CTL3=8;
  ATD0CTL4=0x80;
  ATD0DIEN=0;
  
  ATD1CTL2=0x00;
  ATD1CTL3=8;
  ATD1CTL4=0x80;
  ATD1DIEN=0;
  
  INTCR=0;
  
}

⌨️ 快捷键说明

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