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

📄 main.c

📁 飞思卡尔 x12 系列单片机 xgate应用实例
💻 C
字号:
/******************************************************************************
													            Copyright (c) Freescale 2006
File Name    : $RCSfile: main.c,v $
Current Revision :	$Revision: 1.1 $
PURPOSE: Example 1: Partitioning Events                      
DESCRIPTION:  In this example you will configure the MCU to flash a pattern 
              on the LEDs using the CPU and the XGATE.
                                                                          
UPDATE HISTORY                                                            
REV  AUTHOR    DATE        DESCRIPTION OF CHANGE                          
---  ------    --------    ---------------------                          
1.0                        - initial coding
1.1  b06321    13/12/06    - ported to S12XE

     *******************************************************************
     * File created by: Freescale East Kilbride MCD Applications Group *
     *******************************************************************

******************************************************************************/

#include <hidef.h>      /* common defines and macros */
#include <mc9s12xep100.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12xep100"

#include <string.h>
#include "xgate.h"

#define CPU_Request 0x01;
#define XGate_Request 0x81;

/******************************************************************************
Function Name  : SetupXGATE
Engineer       : r32151	
Date           : 01/03/2005
Parameters     : NONE
Returns        : NONE
Notes          : initialize the XGATE vector block
******************************************************************************/
static void SetupXGATE(void) {
/* initialize the XGATE vector block and set the XGVBR register to its start address */
  XGVBR= (unsigned int)(void*__far)(XGATE_VectorTable - XGATE_VECTOR_OFFSET);

/* enable XGATE mode and interrupts */
  XGMCTL= 0xFBC1; // XGE | XGFRZ | XGIE 
}


/******************************************************************************
Function Name  : main
Engineer       : r32151	
Date           : 01/03/2005
Parameters     : NONE
Returns        : NONE
Notes          : main routine called by Startup.c, 
                  Sets up PORTA as an output
                  Sets up a PIT every 250ms
                  Allocates events between CPU and XGATE
******************************************************************************/
void main(void) {

/* put your own code here */
  SetupXGATE();
  
/* Set up Port A */
  PORTA = 0x00;
  DDRA = 0x0F;
  
/* Enable PIT channel 0 */
  PITCFLMT = 0x80;    // Enable PIT: PITE=1, PIT module enable bit
  PITCE = 0x01;       // PIT channel enable register: PCE0=1 Enable channel
  PITMUX = 0x00;      // Use microtimer base 0 for all channels
  PITINTE = 0x01;     // Enable channel 0 interrupt 
  PITMTLD0 = 200;     // Microtimer count of 200 
  PITLD0 = 5000;      // Channel 0 counter of 5000 
  
/* ALLOCATE EVENT TO CPU OR XGATE */
  INT_CFADDR = 0x70;  // Set interrupt control page to PIT channels 
                      // PIT0 vector address: Vector_Base + 0x7A
 
//  INT_CFDATA5 = CPU_Request;  // Send interrupt to CPU (level 1) 
  INT_CFDATA5 = XGate_Request;  // Send interrupt to XGate (level 1)

  EnableInterrupts;

  for(;;) {} 

}

⌨️ 快捷键说明

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