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

📄 main.c

📁 freescale 协处理器应用相关实例
💻 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 */
  PITCE = 0x01;       /* Enable channel 0 */
  PITMUX = 0x00;      /* Use microtimer 0 for all channels */
  PITINTE = 0x01;     /* Enable channel 0 interrupt */
  PITMTLD0 = 200;     /* Microtimer count of 200 */
  PITLD0 = 10000;      /* Channel 0 counter of 10000 */
  
  /* ALLOCATE EVENT TO CPU OR XGATE */
  INT_CFADDR = 0x70;  /* Set interrupt control page to PIT channels */
  INT_CFDATA5 = CPU_Request;  /* Send interrupt to CPU (level 1) */
// INT_CFDATA5 = XGate_Request;  /* Send interrupt to XGate (level 1) */

  EnableInterrupts;
  for(;;) {} /* wait forever */
  /* please make sure that you never leave this function */
}

⌨️ 快捷键说明

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