📄 setup_ext_int.c
字号:
/*********************************************************************
*
* Copyright: MOTOROLA, INC. All Rights Reserved.
* You are hereby granted a copyright license to use, modify, and
* distribute the SOFTWARE so long as this entire notice is
* retained without alteration in any modified and/or redistributed
* versions, and that such modified versions are clearly identified
* as such. No licenses are granted by implication, estoppel or
* otherwise under any patents or trademarks of Motorola, Inc. This
* software is provided on an "AS IS" basis and without warranty.
*
* To the maximum extent permitted by applicable law, MOTOROLA
* DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
* PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE
* SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY
* ACCOMPANYING WRITTEN MATERIALS.
*
* To the maximum extent permitted by applicable law, IN NO EVENT
* SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING
* WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
* INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
* LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
*
* Motorola assumes no responsibility for the maintenance and support
* of this software
********************************************************************/
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
* File: setup_ext_int.c *
* *
* Setup external interrupts for MPC5xx *
* *
* Last Updated: 02/09/17 14:14 *
* *
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
/*****************************************************************
* *
* In this example, the ISR simply calls a C function. *
* However, since the C function may be out of range for a PC *
* relative call, we will call it using far absolute addressing.*
* *
*****************************************************************/
#include "m_common.h"
#include "mpc500_util.h"
#include "mpc555.h"
/* save current state of section characteristics */
#pragma push
/* change the .text section to far absolute addressing */
#pragma section code_type ".text" code_mode=far_abs
/* tell the compiler to use the current addressing mode for .text */
/* for all calls to ext_Int_Handler(), this must be done before */
/* the first reference or prototype of ext_Int_Handler() */
void ext_Int_Handler(void);
/* create new code section called .ext_isr */
#pragma section code_type ".ext_isr"
/* use .ext_isr as the default section for code, this must be */
/* done before the first reference or prototype of external_isr() */
void external_isr();
/* mods are done, restore the state of the sections, .text will go */
/* back to being PC relative and the default section for all code */
#pragma pop
#pragma interrupt SRR on
void external_isr()
{
ext_Int_Handler();
}
#pragma interrupt off
/*******************************************************************************************
FUNCTION : setup_ext_int
PURPOSE : sets up the MPC5xx to respond to external interrupts
INPUT NOTES : None
RETURN NOTES : None
GENERAL NOTES : Enables the U-interface to pass on interrupts to PowerPC
*******************************************************************************************/
void setup_ext_int (void)
{
struct USIU_tag *usiu = &USIU; /* pointer for USIU */
usiu->SIMASK.R = SIU_INT_LEVEL2; /* enable only interrupt level 2 */
asm
{
mtspr EIE,r7 /* Enable the MSR[EE] and MSR[RI] bits to setup interrupts */
mfmsr r3 /* MSR = external interrupts enabled, floating point enabled, */
ori r3,r3,0x3002 /* machine checks enabled and exception table at 0x00000000 */
mtmsr r3
}
}
/*******************************************************************************************
FUNCTION : InterruptHandler
PURPOSE : dummy interrupt handler
INPUT NOTES :
RETURN NOTES :
GENERAL NOTES :
*******************************************************************************************/
void InterruptHandler()
{
while (1)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -