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

📄 cpu.c

📁 XML6122V4金旅电压表程序 XML6122V4金旅电压表程序 XML6122V4金旅电压表程序 XML6122V4金旅电压表程序
💻 C
字号:
/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : Cpu.C
**     Project   : dy
**     Processor : MC9S08QD4CSC
**     Beantype  : MC9S08QD4_8
**     Version   : Bean 01.026, Driver 01.27, CPU db: 2.87.049
**     Datasheet : MC9S08QD4 Rev. 2 Draft B (Release Candidate) 11/2006
**     Compiler  : CodeWarrior HCS08 C Compiler
**     Date/Time : 2008-3-13, 11:04
**     Abstract  :
**         This bean "MC9S08QD4_8" contains initialization of the
**         CPU and provides basic methods and events for CPU core
**         settings.
**     Settings  :
**
**     Contents  :
**         EnableInt  - void Cpu_EnableInt(void);
**         DisableInt - void Cpu_DisableInt(void);
**         Delay100US - void Cpu_Delay100US(word us100);
**
**     (c) Copyright UNIS, spol. s r.o. 1997-2006
**     UNIS, spol. s r.o.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/

/* MODULE Cpu. */

#pragma MESSAGE DISABLE C4002 /* WARNING C4002: Result not used is ignored */

#include "AD1.h"
#include "WDog1.h"
#include "Bit1.h"
#include "Bit2.h"
#include "Bit3.h"
#include "Bit4.h"
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
#include "Events.h"
#include "Cpu.h"


/* Global variables */
volatile byte CCR_reg;                 /* Current CCR register */

/*Definition of global shadow variables*/
byte Shadow_PTA;


/*
** ===================================================================
**     Method      :  Cpu_Interrupt (bean MC9S08QD4_8)
**
**     Description :
**         The method services unhandled interrupt vectors.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
ISR(Cpu_Interrupt)
{
}



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

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

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

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

/*
** ===================================================================
**     Method      :  Cpu_Delay100US (bean MC9S08QD4_8)
**
**     Description :
**         This method realizes software delay. The length of delay
**         is at least 100 microsecond multiply input parameter
**         [us100]. As the delay implementation is not based on real
**         clock, the delay time may be increased by interrupt
**         service routines processed during the delay. The method
**         is independent on selected speed mode.
**     Parameters  :
**         NAME            - DESCRIPTION
**         us100           - Number of 100 us delay repetitions.
**     Returns     : Nothing
** ===================================================================
*/
#pragma NO_ENTRY
#pragma NO_EXIT
#pragma MESSAGE DISABLE C5703
void Cpu_Delay100US(word us100)
{
  /* Total irremovable overhead: 16 cycles */
  /* ldhx: 5 cycles overhead (load parameter into register) */
  /* jsr:  5 cycles overhead (jump to subroutine) */
  /* rts:  6 cycles overhead (return from subroutine) */

  asm {
loop:
    /* 100 us delay block begin */

    /*
     * Delay
     *   - requested                  : 100 us @ 8MHz,
     *   - possible                   : 800 c, 100000 ns
     *   - without removable overhead : 784 c, 98000 ns
     */
    pshh                               /* (2 c: 250 ns) backup H */
    pshx                               /* (2 c: 250 ns) backup X */
    ldhx #0x40                         /* (3 c: 375 ns) number of iterations */
label0:
    STA SRS
    aix #-0x01                         /* (2 c: 250 ns) decrement H:X */
    cphx #0x00                         /* (3 c: 375 ns) compare it to zero */
    bne label0                         /* (3 c: 375 ns) repeat 64x */
    pulx                               /* (3 c: 375 ns) restore X */
    pulh                               /* (3 c: 375 ns) restore H */
    nop                                /* (1 c: 125 ns) wait for 1 c */
    nop                                /* (1 c: 125 ns) wait for 1 c */
    nop                                /* (1 c: 125 ns) wait for 1 c */
    /* 100 us delay block end */
    aix #-0x01                         /* us100 parameter is passed via H:X registers */
    cphx #0x00
    bne loop                           /* next loop */
    rts                                /* return from subroutine */
  }
}

/*
** ===================================================================
**     Method      :  _EntryPoint (bean MC9S08QD4_8)
**
**     Description :
**         Initializes the whole system like timing and so on. At the end 
**         of this function, the C startup is invoked to initialize stack,
**         memory areas and so on.
**         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 NO_FRAME
#pragma NO_EXIT
void _EntryPoint(void)
{
  /* ### MC9S08QD4_8 "Cpu" init code ... */
  /*  PE initialization code after reset */
  /* Common initialization of the write once registers */
  /* SOPT1: COPE=1,COPT=1,STOPE=0,??=1,??=0,??=0,BKGDPE=0,RSTPE=0 */
  setReg8(SOPT1, 0xD0);                 
  /* SPMSC1: LVDF=0,LVDACK=0,LVDIE=0,LVDRE=1,LVDSE=1,LVDE=1,??=0,BGBE=0 */
  setReg8(SPMSC1, 0x1C);                
  /* SPMSC2: LVWF=0,LVWACK=0,LVDV=0,LVWV=0,PPDF=0,PPDACK=0,??=0,PPDC=0 */
  setReg8(SPMSC2, 0x00);                
  /*  System clock initialization */
  ICSTRM = *(unsigned char*)0xFFAF;    /* Initialize ICSTRM register from a non volatile memory */
  ICSSC = *(unsigned char*)0xFFAE;     /* Initialize ICSSC register from a non volatile memory */
  /* ICSC1: ??=0,CLKS=0,??=0,??=0,??=0,??=1,??=1,IREFSTEN=0 */
  setReg8(ICSC1, 0x06);                /* Initialization of the ICS control register 1 */ 
  /* ICSC2: BDIV=0,??=0,??=0,LP=0,??=0,??=0,??=0 */
  setReg8(ICSC2, 0x00);                /* Initialization of the ICS control register 2 */ 
  /* SOPT2: COPCLKS=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
  setReg8(SOPT2, 0x00);                 
  /*** End of PE initialization code after reset ***/

  __asm   jmp _Startup ;               /* Jump to C startup code */

}

/*
** ===================================================================
**     Method      :  PE_low_level_init (bean MC9S08QD4_8)
**
**     Description :
**         Initializes beans and provides common register initialization. 
**         The method is called automatically as a part of the 
**         application initialization code.
**         This method is internal. It is used by Processor Expert only.
** ===================================================================
*/
void PE_low_level_init(void)
{
  /* Common initialization of the CPU registers */
  /* APCTL1: ADPC3=1 */
  setReg8Bits(APCTL1, 0x08);            
  /* PTAD: PTAD4=0,PTAD2=0,PTAD1=0,PTAD0=0 */
  clrReg8Bits(PTAD, 0x17);              
  /* PTAPE: PTAPE4=0,PTAPE2=0,PTAPE1=0,PTAPE0=0 */
  clrReg8Bits(PTAPE, 0x17);             
  /* PTADD: PTADD2=1,PTADD1=1,PTADD0=1 */
  setReg8Bits(PTADD, 0x07);             
  /* PTASE: PTASE4=1,PTASE3=1,PTASE2=1,PTASE1=1,PTASE0=1 */
  setReg8Bits(PTASE, 0x1F);             
  /* PTADS: ??=0,??=0,PTADS5=0,PTADS4=0,PTADS3=0,PTADS2=0,PTADS1=0,PTADS0=0 */
  setReg8(PTADS, 0x00);                 
  /* ### Shared modules init code ... */
  /* ###  "AD1" init code ... */
  AD1_Init();
  /* ###  WatchDog "WDog1" init code ... */
  SRS = 0xFF;
  /* ### BitIO "Bit1" init code ... */
  Shadow_PTA &= ~0x01;                 /* Initialize pin shadow variable bit */
  /* ### BitIO "Bit2" init code ... */
  Shadow_PTA &= ~0x02;                 /* Initialize pin shadow variable bit */
  /* ### BitIO "Bit3" init code ... */
  Shadow_PTA &= ~0x04;                 /* Initialize pin shadow variable bit */
  /* ### BitIO "Bit4" init code ... */
  __EI();                              /* Enable interrupts */
}

/* Initialization of the CPU registers in FLASH */

/* NVPROT: FPS=0x7F,FPDIS=1 */
const unsigned char NVPROT_INIT @0x0000FFBD = 0xFF;

/* NVOPT: KEYEN=0,FNORED=1,??=1,??=1,??=1,??=1,SEC01=1,SEC00=0 */
const unsigned char NVOPT_INIT @0x0000FFBF = 0x7E;

/* END Cpu. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 3.00 [03.89]
**     for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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