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

📄 pwm_phs.c

📁 freescale最新的16位单片机
💻 C
字号:

/* MODULE PWM0. */

#include "PWM_phs.h"
#include "con_msg_dis.h"  // Disable some warning messages, add by rc574c 10-Jan-2006
// #include "PE_Error.h"

/* Definition of DATA and CODE segments for this bean. User can specify where
   these segments will be located on "Build options" tab of the selected CPU bean. */


/*
** ===================================================================
**     Method      :  PWM_Init (bean PWM)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/
#define output(P, V) P = (V)
#define input(P) (P)

void PWM_Init(void){
  
 /* Common initialization of the CPU registers */
/* PWME: PWME7=0,PWME6=0,PWME5=0,PWME4=0,PWME3=0,PWME2=0,PWME1=0,PWME0=0 */
  output( PWME, 0 );
/* PWMCTL: CON23=1,CON01=0,PSWAI=0,PFRZ=0 */
  output( PWMCTL, input( PWMCTL ) & ~28 | 32 );
/* PWMCAE: CAE3=0,CAE0=0 */
  output( PWMCAE, input( PWMCAE ) & ~9 );
/* PWMPOL: PPOL3=1,PPOL0=1 */
  output( PWMPOL, input( PWMPOL ) | 9 );
  
// Already initialized in pim.c file of S12X demo project  
/* PTP: PTP3=1,PTP0=1 */
  //output( PTP, input( PTP ) | 9 ); 
/* DDRP: DDRP3=1,DDRP0=1 */
  //output( DDRP, input( DDRP ) | 9 );
  
  
/* PWMSDN: PWMIF=0,PWMIE=0,PWMRSTRT=0,PWMLVL=0,??=0,PWM7IN=0,PWM7INL=0,PWM7ENA=0 */
  output( PWMSDN, 0 );

  PWM0_Init();
  PWM23_Init();


/* TSCR1: TSWAI=0,TSFRZ=0 */
//  output( TSCR1, input( TSCR1 ) & ~96 );					// TBC ???????????????????????????
/* MCCTL: MODMC=1 */
  output( MCCTL, input( MCCTL ) | 64 );


}

/*
** ===================================================================
**     Method      :  PWM0_Init (bean PWM)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/
void PWM0_Init(void)
{

  PWMCNT0 = 0;
  PWMDTY0 = 10;//10; //4;//20; //4 Cal;                         /* Store initial value to the duty-compare register */
  PWMPER0 = 20; //8;//40; //8 Freq; //20                       /* and to the period register */
  /* PWMPRCLK: ??=0,PCKB2=0,PCKB1=0,PCKB0=0,??=0,PCKA2=0,PCKA1=0,PCKA0=0 */
  //PWMPRCLK = 0x00;                        /* Set prescaler register */
  /* PWMSCLA: BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=0,BIT0=1 */
  PWMSCLA = 0;                         /* Set scale register */
  PWMCLK_PCLK0 = 0;                    /* Select clock source */
  PWME_PWME0 = 1;                      /* Run counter */
}


/*
** ===================================================================
**     Method      :  PWM23_Init (bean PWM)
**
**     Description :
**         This method is internal. It is used by Processor Expert
**         only.
** ===================================================================
*/


void PWM23_Init(void)
{
// unsigned int Cal;


  PWMCNT23 = 0;
//  PWMDTY23 = 7040; //Cal = 11/12 for Marelli screen;   /* Store initial value to the duty-compare register */
  PWMDTY23 =500;//9760;//1760;//9760;//6912;//1382;//6912;// new test//128;//640; //Cal = 1/12 for Motorola screen;   /* Store initial value to the duty-compare register */
						
  PWMPER23 =1000;//1840;//9840;//40MHz * 242 * 1us//7680;//1536;//7680;//1536;//7680; //Cal;                        /* and to the period register */
  /* PWMPRCLK: ??=0,PCKB2=0,PCKB1=0,PCKB0=0,??=0,PCKA2=0,PCKA1=0,PCKA0=0 */
  //PWMPRCLK = 0;                        /* Set prescaler register */
  /* PWMSCLB: BIT7=0,BIT6=0,BIT5=0,BIT4=0,BIT3=0,BIT2=0,BIT1=0,BIT0=1 */
  PWMSCLB = 0;                         /* Set scale register */
  PWMCLK_PCLK3 = 0;                    /* Select clock source  */
  PWME_PWME3 = 1;                      /* Run counter */
}

/* END PWM23. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 03.33 for 
**     the Motorola HCS12 series of microcontrollers.
**
** ###################################################################
*/

⌨️ 快捷键说明

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