pwm.c

来自「freescale最新的16位单片机」· C语言 代码 · 共 54 行

C
54
字号
/******************************************************************************
*
* Freescale Semiconductor Inc.
* (c) Copyright 2004-2005 Freescale Semiconductor, Inc.
* ALL RIGHTS RESERVED.
*
***************************************************************************//*!
*
* @file      pwm.c
*
* @author    R89994
* 
* @version   1.0.6.0
* 
* @date      Jul-27-2006
* 
* @brief     Setting of periphery PWM
*
*******************************************************************************/

#include "main.h"
#include "pwm.h"


/******************************************************************************
* Module            : void SetupPWM(void)
* Description       : initialization PWM module
* Global Data       : none
* Static Global Data: none
* Returns           : none
* Arguments         : none
* Special Issues    : none
******************************************************************************/

void SetupPWM(void)
{
    PWMPOL    = 0x20;		    // polarity
    PWMCLK    = 0x00;		    // clock
    PWMPRCLK  = 0x60;	      // clock prescaler
    PWMCAE    = 0x00;       // no center aligned
    PWMCTL    = 0x18;       // control register
    PWMSCLA   = 0x00;       // scale A register
    PWMSCLB   = 0x00;       // scale B register
    PWMSDN    = 0x00;       // shutdown register for channel 7   

    PWME_PWME6 = 1;         // PWM6 Enabled 
    PWME_PWME7 = 1;         // PWM7 Enabled 
      
    PWMCNT6 = 0x00;    
    PWMPER6 = 0xFF;    

    PWMCNT7 = 0x00;    
    PWMPER7 = 0xFF;    
}

⌨️ 快捷键说明

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