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

📄 s12_flash.h

📁 PWM Generation Using HCS12 Timer Channels
💻 H
字号:
/*****************************************************************************/
/*                                             COPYRIGHT (c) MOTOROLA 2002   */
/*                                                                           */
/* File Name          :    $RCSfile: s12_flash.h,v $						 */
/*                                                                           */
/* Current Revision :      $Revision: 1.2 $                                  */
/*                                                                           */
/* PURPOSE: header file for HCS12 Flash control registers block	   			 */
/*                                                                           */
/*  ***********************************************************************  */
/*  *  THIS CODE IS ONLY INTENDED AS AN EXAMPLE OF CODE FOR THE           *  */
/*  *  METROWERKS COMPILER AND THE STAR12 EVB AND HAS ONLY BEEN GIVEN A   *  */
/*  *  MIMIMUM LEVEL OF TEST. IT IS PROVIDED 'AS SEEN' WITH NO GUARANTEES *  */
/*  *  AND NO PROMISE OF SUPPORT.                                         *  */
/*  ***********************************************************************  */
/*                                                                           */
/*                                                                           */
/* DESCRIPTION:  Defines the Flash control registers block as a datastructure*/
/*               of type tFLASH.                                             */
/* 																		     */
/* Flash control module base address (out of reset) -                        */
/*                                                                           */
/* S12DP256      : 0x0100                                                    */
/*																			 */
/* The datastructure compiled can be determined by the #define's S12DP256,   */
/* S12xxx, etc. These definitions can be found in "s12_common.h".            */
/* The MCU id can be #defined in a "target.h" header file or included as a   */
/* complier command line argument as -DS12DP256.                             */
/* Currently only S12DP256 is supported.									 */
/*																			 */
/* Multiple register descriptions are used when a differing bit structure    */
/* exists between parts. In the case of additional bit definitions within    */
/* the same register, then only the full register description is used.       */
/*                                                                           */
/*                                                                           */
/* AUTHOR: R32151            LOCATION: SPSEKB      LAST EDIT DATE: 14/03/02  */
/*                                                                           */
/* UPDATE HISTORY                                                            */
/* REV  AUTHOR       DATE       DESCRIPTION OF CHANGE                        */
/* ---  ------      --------    ---------------------                        */
/* 1.00	r32151  	11/05/00                                                 */
/* 1.01	r32151  	25/05/00  	- Corrected declaration of rsvfee2 (reserved */
/*                                area for test). 		                     */
/* 1.1  r32151      11/03/02	- Added disclaimer and reformated file info. */
/*                              - Modified revision numbering to match RCS   */
/* 1.2  r32151      14/03/02	- Declared all registers volatile 	 	     */
/*                                                                           */
/*===========================================================================*/
/* Motorola reserves the right to make changes without further notice to any */
/* product herein to improve reliability, function, or design. Motorola 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.  Motorola */
/* 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 Motorola product  could create a situation where */
/* personal injury or death may occur. Should Buyer purchase or use Motorola */
/* products for any such intended  or unauthorized  application, Buyer shall */
/* indemnify and  hold  Motorola  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  Motorola */
/* was negligent regarding the  design  or manufacture of the part. Motorola */
/* and the Motorola logo* are registered trademarks of Motorola Ltd.         */
/*****************************************************************************/

#ifndef S12_FLASH_H			/*prevent duplicated includes */
#define S12_FLASH_H

#ifndef S12_COMMON_H		/*prevent duplicated includes */
#include "s12_common.h"
#endif

typedef union uFCLKDIV
  {
  tU08	byte;
  struct
    {
    tU08 fdiv	:6;		/*clk divider */
    tU08 fdiv8	:1;		/*clk /8 prescaler enable */
    tU08 fdivld	:1;		/*clock divider loaded flag */
    }bit;
  }tFCLKDIV;

#define FDIV	0x3F	/*bit masks	*/
#define FDIV8	0x40
#define FDIVLD	0x80

typedef union uFSEC
  {
  tU08	byte;
  struct
    {
    tU08 sec0	:1;		/*memory security bit0 */
    tU08 sec1   :1;		/*memory security bit1 */
    tU08 nv		:5;		/*user non volatile flag bits */
    tU08 keyen	:1;		/*security key access enable */
    }bit;
  }tFSEC;

#define SEC00	0x01	/*bit masks	*/
#define SEC01	0x02
#define NV2		0x04
#define NV3		0x08
#define NV4		0x10
#define NV5 	0x20
#define NV6		0x40
#define KEYEN	0x80

typedef union uFTSTMOD
  {
  tU08	byte;
  struct
    {
    tU08 		:4;		/*not used */
    tU08 wrall	:1;		/*write all bit */
    tU08 		:3;		/*not used */
    }bit;
  }tFTSTMOD;

#define WRALL	0x10	


typedef union uFCNFG
  {
  tU08	byte;
  struct
    {
    tU08 bksel	:2;		/*register bank select */
    tU08		:3;		/*not used */
    tU08 keyacc	:1;		/*security key writing enable */
    tU08 ccie	:1;		/*command complete interrupt enable */
    tU08 cbeie	:1;		/*command buffer empty interrupt enable	*/
    }bit;
  }tFCNFG;

#define BKSEL0	0x01	/*bit masks	*/
#define BKSEL1	0x02
#define BKSEL	0x03	/*bank select mask */
#define KEYACC	0x20	
#define CCIE	0x40	
#define CCBIE	0x80

typedef union uFPROT
  {
  tU08	byte;
  struct
    {
    tU08 fpls		:2;		/*flash protection lower address size */
    tU08 fpldis		:1;		/*flash protection lower address range disable */
    tU08 fphs		:2;		/*flash protection higher address size */
    tU08 fphdis		:1;		/*flash protection higher address range disable */
    tU08 			:1;		/*contains value of equivalent bit in protection byte */
    tU08 fopen		:1;		/*open block for program/erase control */
    }bit;
  }tFPROT;

#define FPLS0		0x01	/*bit masks	*/
#define FPLS1		0x02
#define FPLS		0x03	/*fpls block size mask */
#define FPLDIS		0x04	
#define FPHS0		0x08	
#define FPHS1		0x10
#define FPHS		0x18	/*fphs block size mask */
#define FPHDIS		0x20	
#define FOPEN		0x80

typedef union uFSTAT
  {
  tU08	byte;
  struct
    {
    tU08 		:2;		/*not used */
    tU08 blank	:1;		/*blank verify flag */
    tU08 		:1;		/*not used */
    tU08 accerr	:1;		/*access error flag */
    tU08 pviol	:1;		/*protection violation flag */
    tU08 ccif	:1;		/*command complete interrupt flag */
    tU08 cbeif	:1;		/*command buffer empty interrupt flag */
    }bit;
  }tFSTAT;

#define BLANK	0x04	/*bit masks	*/
#define ACCERR	0x10
#define PVIOL 	0x20
#define CCIF	0x40
#define CBEIF	0x80

typedef union uFCMD
  {
  tU08	byte;
  struct
    {
    tU08 mass	:1;		/*mass erase enable	*/
	tU08 		:1;		/*not used */
    tU08 erver	:1;		/*erase verify enable */
	tU08 		:2;		/*not used */
    tU08 prog	:1;		/*word programming */
    tU08 erase	:1;		/*erase control */
	tU08 		:1;		/*not used */
    }bit;
  }tFCMD;

#define MASS	0x01	/*bit masks	*/
#define ERVER	0x04
#define PROG	0x20
#define ERASE	0x40


typedef struct						/*flash datastructure */
  {
  volatile tFCLKDIV		fclkdiv;	/*flash clock divider register */
  volatile tFSEC		fsec;		/*flash security register */
  volatile tFTSTMOD	    ftstmod;	/*flash test register */
  volatile tFCNFG		fcnfg;		/*flash configuration register */
  volatile tFPROT		fprot;		/*flash protection register */
  volatile tFSTAT		fstat;		/*flash status register */
  volatile tFCMD		fcmd;		/*flash command buffer & status register */
 		   tU08			rsvfee2;	/*reserved */
  volatile tREG16       faddr;		/*WORD - flash address registers */
  volatile tREG16       fdata;		/*WORD - flash data registers */
  		   tU08         rsvfee3[4];	/*reserved */
  }tFLASH;


#endif /*S12_FLASH_H */

⌨️ 快捷键说明

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