/** ###################################################################
**     THIS BEAN MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
**     Filename  : PWM1.C
**     Project   : bldc_hall_demo
**     Processor : MC56F8006_48_LQFP
**     Beantype  : Init_PWM
**     Version   : Bean 01.294, Driver 01.21, CPU db: 3.00.177
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 21.11.2008, 15:13
**     Abstract  :
**         This "Init_PWM" Peripheral Inspector implements the
**         Puls Width Modulator module (PWM), basic initialization
**         and settings.
**     Settings  :
**         PWM module                  : PWM_Timer
**
**         Clock setting
**             PWM prescaler           : 1
**             Counter modulo          : 800
**             Dead time value         : 16
**             Reload frequency        : 1
**             PWM frequency           : 20 kHz
**             PWM period              : 50 us
**             PWM deadtime            : 0.5 us
**
**         Interrupts
**             Reload interrupt        : Disabled
**
**             Fault 0 interrupt       : Disabled
**             Fault 1 interrupt       : Disabled
**             Fault 2 interrupt       : Disabled
**             Fault 3 interrupt       : Disabled
**
**         HW acceleration             : Enabled
**             Load mode               : Write to value reg 0 also writes 1-5
**             Swap & mask operation   : Enhanced
**             Swap PWM channels 0 & 1 : no
**             Swap PWM channels 2 & 3 : no
**             Swap PWM channels 4 & 5 : no
**
**         Correction
**             Method                  : Manual correction or no correction
**             Internal current ctrl.0 : Top
**             Internal current ctrl.1 : Top
**             Internal current ctrl.2 : Top
**
**         Channel settings
**             Alignment               : Center-aligned mode
**             Channels 0-1
**               Mode of PWM           : Complementary
**               Phase shift PWM.      : Disabled
**               Top output polarity   : Positive
**               Bottom output polar.  : Positive
**             Channels 2-3
**               Mode of PWM channels  : Complementary
**               Phase shift PWM.      : Disabled
**               Top output polarity   : Positive
**               Bottom output polar.  : Positive
**             Channels 4-5
**               Mode of PWM channels  : Complementary
**               Phase shift PWM.      : Disabled
**               Top output polarity   : Positive
**               Bottom output polar.  : Positive
**
**         Enabled in wait mode        : no
**         Enabled in EnOnCE mode      : no
**         Write protect               : no
**         Output pads                 : Enabled
**         Half cycle reload           : no
**
**         Channel 0
**             PWM Pin                 : GPIOA0_PWM0
**             Enable software control : no
**             Channel masked          : no
**
**         Channel 1
**             PWM Pin                 : GPIOA1_PWM1
**             Enable software control : no
**             Channel masked          : no
**
**         Channel 2
**             PWM Pin                 : GPIOA2_PWM2
**             Enable software control : no
**             Channel masked          : no
**
**         Channel 3
**             PWM Pin                 : GPIOA3_PWM3_TXD_EXTAL
**             Enable software control : no
**             Channel masked          : no
**
**         Channel 4
**             PWM Pin                 : GPIOA4_PWM4_FAULT1_SDA_TIN2
**             Enable software control : no
**             Channel masked          : no
**
**         Channel 5
**             PWM Pin                 : GPIOA5_PWM5_FAULT2_EXT_SYNC_TIN3
**             Enable software control : no
**             Channel masked          : no
**         Fault 0
**             clearing mode           : Manual
**             fault polarity          : Positive
**             glitch stretch          : Disabled
**         Fault 1
**             clearing mode           : Manual
**             fault polarity          : Positive
**             glitch stretch          : Disabled
**         Fault 2
**             clearing mode           : Manual
**             fault polarity          : Positive
**             glitch stretch          : Disabled
**         Fault 3
**             clearing mode           : Manual
**             fault polarity          : Positive
**             glitch stretch          : Disabled
**
**         Synchronization
**             output                  : Disabled
**             windowed input          : Disabled
**
**         Initialization
**             Call Init method        : yes
**             Enable peripheral clock : yes
**             Load values after init  : yes
**             Enable PWM generator    : yes
**
**     Contents  :
**         Init - void PWM1_Init(void);
**
**     (c) Copyright UNIS, a.s. 1997-2008
**     UNIS, a.s.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/

/* MODULE PWM1. */

#include "PWM1.h"

/*
** ===================================================================
**     Method      :  PWM1_Init (bean Init_PWM)
**
**     Description :
**         Peripheral Initialization Beans provide a low-level
**         hardware approach to initialize registers of the
**         peripheral module. They are intended for experienced
**         users.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
void PWM1_Init(void)
{
  /* PWM_CTRL: LDFQ=0,HALF=0,IPOL2=0,IPOL1=0,IPOL0=0,PRSC=0,PWMRIE=0,PWMF=0,ISENS=0,LDOK=0,PWMEN=0 */
  setReg16(PWM_CTRL, 0x00);             
  /* PWM_FCTRL: ??=0,??=0,??=0,??=0,FPOL3=0,FPOL2=0,FPOL1=0,FPOL0=0,FIE3=0,FMODE3=0,FIE2=0,FMODE2=0,FIE1=0,FMODE1=0,FIE0=0,FMODE0=0 */
  setReg16(PWM_FCTRL, 0x00);            
  /* PWM_CMOD: ??=0,PWMCM=0x0320 */
  setReg16(PWM_CMOD, 0x0320);           
  /* PWM_VAL0: PMVAL=0x0190 */
  setReg16(PWM_VAL0, 0x0190);           
  /* PWM_VAL1: PMVAL=0x0190 */
  setReg16(PWM_VAL1, 0x0190);           
  /* PWM_VAL2: PMVAL=0x0190 */
  setReg16(PWM_VAL2, 0x0190);           
  /* PWM_VAL3: PMVAL=0x0190 */
  setReg16(PWM_VAL3, 0x0190);           
  /* PWM_VAL4: PMVAL=0x0190 */
  setReg16(PWM_VAL4, 0x0190);           
  /* PWM_VAL5: PMVAL=0x0190 */
  setReg16(PWM_VAL5, 0x0190);           
  /* PWM_DMAP1: DISMAP_15_0=0 */
  setReg16(PWM_DMAP1, 0x00);            
  /* PWM_DMAP2: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,DISMAP_23_16=0 */
  setReg16(PWM_DMAP2, 0x00);            
  /* PWM_DTIM0: ??=0,??=0,??=0,??=0,PWMDT0=0x10 */
  setReg16(PWM_DTIM0, 0x10);            
  /* PWM_DTIM1: ??=0,??=0,??=0,??=0,PWMDT1=0x10 */
  setReg16(PWM_DTIM1, 0x10);            
  /* PWM_SYNC: SYNC_OUT_EN=0,SYNC_WINDOW=0 */
  setReg16(PWM_SYNC, 0x00);             
  setRegBit(PWM_CCTRL, ENHA);          /* Enable HW Acceleration */
  /* PWM_CCTRL: ENHA=1,nBX=1,MSK5=0,MSK4=0,MSK3=0,MSK2=0,MSK1=0,MSK0=0,??=0,??=0,VLMODE=1,??=0,SWP45=0,SWP23=0,SWP01=0 */
  setReg16(PWM_CCTRL, 0xC010);          
  /* PWM_OUT: PAD_EN=1,??=0,OUTCTL5=0,OUTCTL4=0,OUTCTL3=0,OUTCTL2=0,OUTCTL1=0,OUTCTL0=0,??=0,??=0,OUT5=0,OUT4=0,OUT3=0,OUT2=0,OUT1=0,OUT0=0 */
  setReg16(PWM_OUT, 0x8000);            
  /* PWM_ICCTRL: ??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,PEC2=0,PEC1=0,PEC0=0,ICC2=0,ICC1=0,ICC0=0 */
  setReg16(PWM_ICCTRL, 0x00);           
  /* PWM_SCTRL: ??=0,??=0,CINV5=0,CINV4=0,CINV3=0,CINV2=0,CINV1=0,CINV0=0,??=0,SRC2=0,??=0,SRC1=0,??=0,SRC0=0 */
  setReg16(PWM_SCTRL, 0x00);            
  /* PWM_FFILT0: GSTR0=0,??=0,??=0,??=0,??=0,FILT0_CNT=0,FILT0_PER=0 */
  setReg16(PWM_FFILT0, 0x00);           
  /* PWM_FFILT1: GSTR1=0,??=0,??=0,??=0,??=0,FILT1_CNT=0,FILT1_PER=0 */
  setReg16(PWM_FFILT1, 0x00);           
  /* PWM_FFILT2: GSTR2=0,??=0,??=0,??=0,??=0,FILT2_CNT=0,FILT2_PER=0 */
  setReg16(PWM_FFILT2, 0x00);           
  /* PWM_FFILT3: GSTR3=0,??=0,??=0,??=0,??=0,FILT3_CNT=0,FILT3_PER=0 */
  setReg16(PWM_FFILT3, 0x00);           
  /* PWM_CNFG: ??=0,DBG_EN=0,WAIT_EN=0,EDG=0,??=0,TOPNEG45=0,TOPNEG23=0,TOPNEG01=0,??=0,BOTNEG45=0,BOTNEG23=0,BOTNEG01=0,INDEP45=0,INDEP23=0,INDEP01=0,WP=0 */
  setReg16(PWM_CNFG, 0x00);             
  /* PWM_FLTACK: FPIN3=0,FFLAG3=0,FPIN2=0,FFLAG2=0,FPIN1=0,FFLAG1=0,FPIN0=0,FFLAG0=0,??=0,FTACK3=1,DT5=0,DT4_FTACK2=1,DT3=0,DT2_FTACK1=1,DT1=0,DT0_FTACK0=1 */
  setReg16(PWM_FLTACK, 0x55);          /* clear fault flags */ 
  /* PWM_FCTRL: ??=0,??=0,??=0,??=0,FPOL3=0,FPOL2=0,FPOL1=0,FPOL0=0,FIE3=0,FMODE3=0,FIE2=0,FMODE2=0,FIE1=0,FMODE1=0,FIE0=0,FMODE0=0 */
  setReg16(PWM_FCTRL, 0x00);            
  /* PWM_CTRL: LDOK=1 */
  setReg16Bits(PWM_CTRL, 0x02);        /* set LDOK bit */ 
  /* PWM_CTRL: PWMEN=1 */
  setReg16Bits(PWM_CTRL, 0x01);        /* set PWMEN bit */ 
  /* PWM_CTRL: PWMF=0 */
  clrReg16Bits(PWM_CTRL, 0x10);        /* clear PWMF flag */ 
}

/* END PWM1. */

/*
** ###################################################################
**
**     This file was created by UNIS Processor Expert 2.99 [04.17]
**     for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
