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

📄 s12x_e_io.c

📁 freescale 协处理器应用相关实例
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
		                                             COPYRIGHT (c) Freescale 2006   
FILE NAME: S12X_E_IO.C                                                      
                                                                          
PURPOSE: S12X D family i/o configuration      											 
                                                                          
TARGET DEVICE: S12XEP100                                               
                                                                          
INCLUDE FILES: s12_io.h, target.h                                               
                                                                          
FUNCTIONS :  ConfigurePorts                                                    
                                                   
Tasks	 :  none                                                  			 
Hooks   :	 none                                                            
ISRs	 :	 none                                                                
                                                                         
COMPILER: Metrowerks                     
                                                                          
DESCRIPTION: Routine to configure S12XEP100                                             
                                                                          
NOTES
-----
E-clk can be monitored on jumper PE4.
                                                                          
UPDATE HISTORY                                                            
REV      AUTHOR      DATE         DESCRIPTION OF CHANGE                    
---      ------      ---------    ---------------------                   
1.0      r32151      13/10/05     Initial coding 
1.1      r32151      26/01/06     ATD ports corrected
                                                                           

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

                                                                          
******************************************************************************/
/*===========================================================================*/
/* Freescale reserves the right to make changes without further notice to any*/
/* product herein to improve reliability, function, or design. Freescale does*/
/* not assume any  liability arising  out  of the  application or use of any */
/* product,  circuit, or software described herein;  neither  does it convey */
/* any license under its patent rights  nor the  rights of others.  Freescale*/
/* products are not designed, intended,  or authorized for use as components */
/* in  systems  intended  for  surgical  implant  into  the  body, or  other */
/* applications intended to support life, or  for any  other application  in */
/* which the failure of the Freescale product  could create a situation where*/
/* personal injury or death may occur. Should Buyer purchase or use Freescale*/
/* products for any such intended  or unauthorized  application, Buyer shall */
/* indemnify and  hold  Freescale  and its officers, employees, subsidiaries,*/
/* affiliates,  and distributors harmless against all claims costs, damages, */
/* and expenses, and reasonable  attorney  fees arising  out of, directly or */
/* indirectly,  any claim of personal injury  or death  associated with such */
/* unintended or unauthorized use, even if such claim alleges that  Freescale*/
/* was negligent regarding the  design  or manufacture of the part. Freescale*/
/* and the Freescale logo* are registered trademarks of Freescale Ltd.       */
/*****************************************************************************/

/************************* Include Files *************************************/
#include "s12x_peripherals.h"
#include "target.h"  /* includes device peripheral declarations */
#include "S12_io.h"


/************************* typedefs ******************************************/
/* in s12x_vectors.h */
/************************* function prototypes *******************************/
/* in s12x_vectors.h */
//#define ECLK_OUT					/* uncomment for Debug */
/************************* #defines ******************************************/
/* in s12x_vectors.h */
/************************* Constants *****************************************/
#pragma CONST_SEG DEFAULT
/************************* Global Variables **********************************/
#pragma DATA_SEG DEFAULT
/************************* Functions *****************************************/
#pragma CODE_SEG DEFAULT 

/******************************************************************************
Function Name	:	ConfigurePorts
Engineer		   :	r32151
Date			   :	01/03/05
Headers			: 	s12_io.h, target.h
Parameters		:	NONE
Returns			:	NONE
Notes			   :	Code to set up i/o ports 
******************************************************************************/
void
ConfigurePorts(void)
{

/******* CORE PORTS ********/

/* core interrupts */
/* This register register was renamed. On early D, A and H families it is called INTCR,
   on all other families it is called IRQCR. */
	IRQCR.byte = 0;		/* IRQ only responds to falling edge  */
								/*	- note IRQE is write once */								

/*include this line to clear the X-bit in order to enable the XIRQ function */   
//  asm ANDCC #~BIT6;	

/* drive level */
	RDRIV.byte = ALL_REDUCED_DRIVE;						/* core ports reduced drive */
/* Enable Pull devices */
	PUCR.byte 	= ALL_PULLS_ON; 							/* Note: only pull-ups available on core ports */
						  						/* some port E pins require care when using external pull devices*/
						  						/* port E.7: pull up for LC Pierce, tie low for ext osc or full Pierce, */
						  						/*           reset enables internal pull up.                     */
						  						/* port E.5 & E.6 should be pulled down for single chip use      */
						  						/*           reset enables internal pull down.                   */
/* configure port data and direction */
/* PORT A */
	PORTA.byte = ALL_LOW;	   
	DDRA.byte = ALL_INPUTS;
/* PORT B */
	PORTB.byte = ALL_HIGH;	   					
	DDRB.byte = ALL_OUTPUTS; 					    
/* PORT C */
	PORTC.byte = ALL_LOW;	   
	DDRC.byte = ALL_INPUTS;
/* PORT D */
	PORTD.byte = ALL_LOW;	   					
	DDRD.byte = ALL_INPUTS; 					    
/* PORT E */
	PORTE.byte = ALL_LOW;	   
	DDRE.byte = ALL_INPUTS; 		
/* PORT K */
	PORTK.byte = ALL_LOW;	   
	DDRK.byte = ALL_INPUTS;
	
/******* PIM PORTS ********/

/* PORT T */
/* Configure Pull-polarity */
	PPST.byte 	= ALL_PULLED_DOWN;
/* Enable Pull devices */
	PERT.byte 	= ALL_PULLS_ON;
/* drive level */
	RDRT.byte 	= ALL_REDUCED_DRIVE;
/* port data */
	PTT.byte 	= ALL_LOW;   
/* port direction */
	DDRT.byte 	= ALL_INPUTS;

/* PORT S */
/* Configure Pull-polarity */
	PPSS.byte 	= ALL_PULLED_DOWN;
/* Enable Pull devices */

/* Enable Pull devices */
	PERS.byte 	= ALL_PULLS_ON;					
//	PERS.byte 	= BIT7|BIT6|BIT5|BIT4;					/* S12 EVB - no pull devices on port S0-3 due to avoid */ 
																	/* conflict with connections to RS232 transceiver */
/* drive level */
	RDRS.byte 	= ALL_REDUCED_DRIVE;
/* Configure wired-or outputs */
	WOMS.byte 	= 0x00;
/* port data */
	PTS.byte 	= ALL_LOW;	   
/* port direction */
	DDRS.byte 	= ALL_INPUTS;
	
/* PORT M */
/* Configure Pull-polarity */
	PPSM.byte = ALL_PULLED_DOWN;
/* Enable Pull devices */
	PERM.byte 	= ALL_PULLS_ON; 	
//	PERM.byte 	= BIT7|BIT6|BIT5|BIT4|BIT3|BIT2|BIT1; 	/* S12 EVB - no pull device enebled on port M0 as it's */
																  	   /*driven by the CAN transceiver Rx pin */
/* drive level */
	RDRM.byte 	= ALL_REDUCED_DRIVE;
/* Configure wired-or outputs */
	WOMM.byte 	= 0x00;	   
/* port data */
	PTM.byte 	= ALL_LOW;	   
/* port direction */
	DDRM.byte 	= ALL_INPUTS;
	
/* PORT P */
/* Configure Pull-polarity */
	PPSP.byte 	= ALL_PULLED_UP;
/* Enable Pull devices */
	PERP.byte 	= ALL_PULLS_ON;
/* drive level */
	RDRP.byte 	= ALL_REDUCED_DRIVE;						
/* port data */
	PTP.byte 	= ALL_LOW;		   
/* port direction */
	DDRP.byte 	= ALL_INPUTS;     
/* Clear all interrupt flags */
	PIFP.byte 	= 0xFF;
/* Enable interrupts */
	PIEP.byte 	= 0x00;
	
/* PORT H */
/* Configure Pull-polarity */
	PPSH.byte 	= ALL_PULLED_UP;	/* EVB - PortH should always pulled up */
/* Enable Pull devices */
	PERH.byte 	= ALL_PULLS_ON;								
/* drive level */
	RDRH.byte 	= ALL_REDUCED_DRIVE;
/* port data */
	PTH.byte 	= ALL_LOW;	   
/* port direction */
	DDRH.byte 	= ALL_INPUTS;
//	DDRH.byte 	= 0x0F;           /* S12X EVB, LEDs on lower nibble, switches on upper - pull up */
/* Clear all interrupt flags */
	PIFH.byte 	= 0xFF;
/* Enable interrupts */
	PIEH.byte 	= 0x00;

/* PORT J */
/* Configure Pull-polarity */
	PPSJ.byte 	= ALL_PULLED_DOWN;
/* Enable Pull devices */

⌨️ 快捷键说明

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