📄 main.c
字号:
/******************************************************************************
Copyright (c) Freescale 2006
File Name : $RCSfile: main.c,v $
Current Revision : $Revision: 1.1 $
PURPOSE: Example 2: Scalable Event Handling
DESCRIPTION: In this example you will configure a single ISR to handle four
interrupts.
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 required ports and PIT
Allocates events between CPU and XGATE
******************************************************************************/
void main(void)
{
char portValue;
/* put your own code here */
SetupXGATE();
/* Set up DIP switches Port B */
PORTB = 0x00;
DDRB = 0x00;
PUCR = 0x42;
/* Set up LEDs Port A */
PORTA = 0xFF;
DDRA = 0x0F;
/* Enable PIT channels 0-3 */
PITCFLMT = 0x80; /* Enable PIT */
PITCE = 0x0F; /* Enable channel 0-3 */
PITMUX = 0x00; /* Use microtimer 0 for all channels */
PITMTLD0 = 100; /* Microtimer count of 100 */
PITLD0 = 5000; /* Channel 0 counter of 5000 */
PITLD1 = 7500; /* Channel 1 counter of 75000 */
PITLD2 = 10000; /* Channel 2 counter of 10000 */
PITLD3 = 12500; /* Channel 3 counter of 12500 */
/* ALLOCATE EVENT TO CPU OR XGate */
INT_CFADDR = 0x70; /* Set interrupt control page to PIT channels */
INT_CFDATA2 = XGate_Request; /* Send interrupt to XGate (level 1) */
INT_CFDATA3 = XGate_Request; /* Send interrupt to XGate (level 1) */
INT_CFDATA4 = XGate_Request; /* Send interrupt to XGate (level 1) */
INT_CFDATA5 = XGate_Request; /* Send interrupt to XGate (level 1) */
for(;;)
{
portValue = PORTB;
PITINTE = portValue; /* Enable/disable PIT channel interrupts */
} /* wait forever */
/* please make sure that you never leave this function */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -