pwm.c
来自「freescale芯片9s12dp256的示例程序」· C语言 代码 · 共 20 行
C
20 行
#include <mc9s12c32.h> /* derivative information */
#include "can.h"
#include "io.h"
#include "pwm.h"
#include "sci.h"
#include "timer.h"
void PWM_Init(void)
{
PWMCNT0 = 0;
PWMDTY0 = 0x6B; // Store initial value to the duty-compare register
PWMPER0 = 0xFF; // 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=1,BIT5=0,BIT4=0,BIT3=1,BIT2=0,BIT1=1,BIT0=1
PWMSCLA = 0x4B; // Set scale register
PWMCLK_PCLK0 = 1; // Select clock source
PWME_PWME0 = 1; // Run counter
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?