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

📄 cpu.c

📁 飞思卡尔智能车的程序。红外循迹
💻 C
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : Cpu.C
**     Project   : che_free
**     Processor : MC9S12DG128BCPV
**     Beantype  : MC9S12DG128_112
**     Version   : Bean 01.167, Driver 01.20, CPU db: 2.87.280
**     Datasheet : 9S12DT128BDGV1/D V01.05
**     Compiler  : Metrowerks HC12 C Compiler
**     Date/Time : 2008-3-24, 下午 08:47
**     Abstract  :
**         This bean "MC9S12DG128_112" implements properties, methods,
**         and events of the CPU.
**     Settings  :
**
**     Contents  :
**         EnableInt   - void Cpu_EnableInt(void);
**         DisableInt  - void Cpu_DisableInt(void);
**         SetWaitMode - void Cpu_SetWaitMode(void);
**         SetStopMode - void Cpu_SetStopMode(void);
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2005
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/

/* MODULE Cpu. */

#include "PWM8Di.h"
#include "TI1.h"
#include "AD2.h"
#include "AD3.h"
#include "PWM8h.h"
#include "PWMd.h"
#include "IEE1.h"
#include "TI2.h"
#include "Events.h"
#include "Cpu.h"

#define CGM_DELAY  3071UL

#pragma DATA_SEG DEFAULT

/* Global variables */
volatile byte CCR_reg;                 /* Current CCR reegister */
byte CpuMode = HIGH_SPEED;             /* Current speed mode */


/*
** ===================================================================
**     Method      :  Cpu_Interrupt (bean MC9S12DG128_112)
**
**     Description :
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
#pragma CODE_SEG __NEAR_SEG NON_BANKED

ISR(Cpu_Interrupt)
{
}

#pragma CODE_SEG DEFAULT

/*
** ===================================================================
**     Method      :  Cpu_DisableInt (bean MC9S12DG128_112)
**
**     Description :
**         Disable maskable interrupts
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_DisableInt(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_EnableInt (bean MC9S12DG128_112)
**
**     Description :
**         Enable maskable interrupts
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_EnableInt(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_SetStopMode (bean MC9S12DG128_112)
**
**     Description :
**         Set low power mode - Stop mode.
**         For more information about the stop mode see
**         documentation of this CPU.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_SetStopMode(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  Cpu_SetWaitMode (bean MC9S12DG128_112)
**
**     Description :
**         Set low power mode - Wait mode.
**         For more information about the wait mode see
**         documentation of this CPU.
**         Release from Wait mode: Reset or interrupt
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
/*
void Cpu_SetWaitMode(void)

**      This method is implemented as macro in the header module. **
*/

/*
** ===================================================================
**     Method      :  _EntryPoint (bean MC9S12DG128_112)
**
**     Description :
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
extern void _Startup(void);            /* Forward declaration of external startup function declared in file Start12.c */
#pragma CODE_SEG __NEAR_SEG NON_BANKED

#define INITRG_ADR  0x0011             /* Register map position register */

#pragma NO_FRAME
#pragma NO_EXIT
void _EntryPoint(void)
{
  /*** ### MC9S12DG128BCPV "Cpu" init code ... ***/
  /*** PE initialization code after reset ***/
  /* Initialization of the registers INITRG, INITRM, INITEE is done to protect them to be written accidentally later by the application */
  *(byte*)INITRG_ADR = 0;              /* Set the register map position */
  asm("nop");                          /* nop instruction */
  /* INITRM: RAM15=0,RAM14=0,RAM13=1,RAM12=0,RAM11=0,??=0,??=0,RAMHAL=0 */
  setReg8(INITRM, 32);                 /* Set the RAM map position */ 
  /* INITEE: EE15=0,EE14=0,EE13=0,EE12=1,??=1,??=0,??=0,EEON=1 */
  setReg8(INITEE, 25);                 /* Set the EEPROM map position */ 
  /* MISC: ??=0,??=0,??=0,??=0,EXSTR1=1,EXSTR0=1,ROMHM=0,ROMON=1 */
  setReg8(MISC, 13);                    
  /* PEAR: NOACCE=0,??=0,PIPOE=0,NECLK=1,LSTRE=0,RDWE=0,??=0,??=0 */
  setReg8(PEAR, 16);                    
  /* CLKSEL: PLLSEL=0,PSTP=0,SYSWAI=0,ROAWAI=0,PLLWAI=0,CWAI=0,RTIWAI=0,COPWAI=0 */
  setReg8(CLKSEL, 0);                  /* Select clock source from XTAL and set bits in CLKSEL reg. */ 
  /* PLLCTL: PLLON=0 */
  clrReg8Bits(PLLCTL, 64);             /* Disable the PLL */ 
  /* SYNR: ??=0,??=0,SYN5=0,SYN4=0,SYN3=0,SYN2=0,SYN1=1,SYN0=0 */
  setReg8(SYNR, 2);                    /* Set the multiplier register */ 
  /* REFDV: ??=0,??=0,??=0,??=0,REFDV3=0,REFDV2=0,REFDV1=0,REFDV0=1 */
  setReg8(REFDV, 1);                   /* Set the divider register */ 
  /* PLLCTL: CME=0,PLLON=1,AUTO=1,ACQ=1,??=0,PRE=0,PCE=0,SCME=0 */
  setReg8(PLLCTL, 112);                 
  while(!CRGFLG_LOCK) {};              /* Wait */
  /* CLKSEL: PLLSEL=1 */
  setReg8Bits(CLKSEL, 128);            /* Select clock source from PLL */ 
  /*** End of PE initialization code after reset ***/
  __asm("jmp _Startup");               /* Jump to C startup code */
}

#pragma CODE_SEG DEFAULT

/*
** ===================================================================
**     Method      :  PE_low_level_init (bean MC9S12DG128_112)
**
**     Description :
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  /* Common initialization of the CPU registers */
  /* PWME: PWME7=0,PWME6=0,PWME5=0,PWME4=0,PWME3=0,PWME2=0,PWME1=0,PWME0=0 */
  setReg8(PWME, 0);                     
  /* PWMCTL: CON23=0,CON01=1,PSWAI=0,PFRZ=0 */
  clrSetReg8Bits(PWMCTL, 44, 16);       
  /* PWMCAE: CAE3=0,CAE2=0,CAE1=0 */
  clrReg8Bits(PWMCAE, 14);              
  /* PWMPOL: PPOL3=0,PPOL2=0,PPOL1=0 */
  clrReg8Bits(PWMPOL, 14);              
  /* PTP: PTP3=0,PTP2=0,PTP1=0 */
  clrReg8Bits(PTP, 14);                 
  /* DDRP: DDRP3=1,DDRP2=1,DDRP1=1 */
  setReg8Bits(DDRP, 14);                
  /* TSCR1: TEN=0,TSWAI=0,TSFRZ=0,TFFCA=0 */
  clrReg8Bits(TSCR1, 240);              
  /* OC7M: OC7M2=0,OC7M0=0 */
  clrReg8Bits(OC7M, 5);                 
  /* TIOS: IOS2=1,IOS0=1 */
  setReg8Bits(TIOS, 5);                 
  /* TCTL2: OM2=0,OL2=0,OM0=0,OL0=0 */
  clrReg8Bits(TCTL2, 51);               
  /* TTOV: TOV2=0,TOV0=0 */
  clrReg8Bits(TTOV, 5);                 
  /* TSCR2: TCRE=0,PR2=1,PR1=1,PR0=1 */
  clrSetReg8Bits(TSCR2, 8, 7);          
  /* TFLG1: C7F=1,C6F=1,C5F=1,C4F=1,C3F=1,C2F=1,C1F=1,C0F=1 */
  setReg8(TFLG1, 255);                  
  /* TIE: C2I=1,C0I=1 */
  setReg8Bits(TIE, 5);                  
  /* ATD0DIEN: IEN7=0,IEN6=0,IEN5=0,IEN4=0,IEN3=0,IEN2=0,IEN1=0,IEN0=0 */
  setReg8(ATD0DIEN, 0);                 
  /* ATD1DIEN: IEN0=0 */
  clrReg8Bits(ATD1DIEN, 1);             
  /* PWMSDN: PWMIF=0,PWMIE=0,PWMRSTRT=0,PWMLVL=0,??=0,PWM7IN=0,PWM7INL=0,PWM7ENA=0 */
  setReg8(PWMSDN, 0);                   
  /* ICSYS: SH37=0,SH26=0,SH15=0,SH04=0,TFMOD=0,PACMX=0,BUFEN=0,LATQ=0 */
  setReg8(ICSYS, 0);                    
  /* MCCTL: MODMC=1 */
  setReg8Bits(MCCTL, 64);               
  /* ### MC9S12DG128_112 "Cpu" init code ... */

  /* ### Programable pulse generation "PWM8Di" init code ... */
  PWM8Di_Init();
  /* ### TimerInt "TI1" init code ... */
  /* TC0: BIT15=0,BIT14=0,BIT13=0,BIT12=0,BIT11=1,BIT10=1,BIT9=1,BIT8=0,BIT7=1,BIT6=0,BIT5=1,BIT4=0,BIT3=0,BIT2=1,BIT1=1,BIT0=0 */
  setReg16(TC0, 3750);                 /* Store given value to the compare register */ 
  /* ###  "AD2" init code ... */
  AD2_Init();
  /* ###  "AD3" init code ... */
  AD3_Init();
  /* ### Programable pulse generation "PWM8h" init code ... */
  PWM8h_Init();
  /* ### Programable pulse generation "PWMd" init code ... */
  PWMd_Init();
  /* ### IntEEPROM "IEE1" init code ... */
  IEE1_Init();
  /* ### TimerInt "TI2" init code ... */
  /* TC2: BIT15=1,BIT14=1,BIT13=0,BIT12=1,BIT11=1,BIT10=0,BIT9=1,BIT8=1,BIT7=1,BIT6=0,BIT5=1,BIT4=1,BIT3=1,BIT2=0,BIT1=1,BIT0=0 */
  setReg16(TC2, 56250);                /* Store given value to the compare register */ 
 /* Common peripheral initialization - ENABLE */
  /* TSCR1: TEN=1 */
  setReg8Bits(TSCR1, 128);              
  /* INTCR: IRQEN=0 */
  clrReg8Bits(INTCR, 64);              /* Disable the IRQ interrupt. IRQ interrupt is enabled after CPU reset by default. */ 
  __EI();                              /* Enable interrupts */
}

/* END Cpu. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 2.96 [03.76]
**     for the Freescale HCS12 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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