📄 pwm_motor.c
字号:
/** ###################################################################
** Filename : pwm_motor.C
** Project : pwm_motor
** Processor : 56F8346
** Version : Driver 01.10
** Compiler : Metrowerks DSP C Compiler
** Date/Time : 2009-1-7, 11:09
** Abstract :
** Main module.
** Here is to be placed user's code.
** Settings :
** Contents :
** No public methods
**
** (c) Copyright UNIS, spol. s r.o. 1997-2005
** UNIS, spol. s r.o.
** Jundrovska 33
** 624 00 Brno
** Czech Republic
** http : www.processorexpert.com
** mail : info@processorexpert.com
** ###################################################################*/
/* MODULE pwm_motor */
/* Including used modules for compiling procedure */
#include "Cpu.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
void main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
PESL(PWMB, PWM_SET_PRESCALER,PWM_PRESCALER_DIV_8);/*configure PWM timing*/
PESL(PWMB, PWM_SET_MODULO,1875);
PESL(PWMB, PWM_SET_DEADTIME,240);/*set deadtime*/
PESL(PWMB, PWM_WRITE_VALUE_REG_0, 1046);/* Initialize Duty Cycle for complimentary channels*/
PESL(PWMB, PWM_WRITE_VALUE_REG_1, 469);
PESL(PWMB, PWM_WRITE_VALUE_REG_2, 1046);
PESL(PWMB, PWM_WRITE_VALUE_REG_3, 469);
PESL(PWMB, PWM_WRITE_VALUE_REG_4, 1046);
PESL(PWMB, PWM_WRITE_VALUE_REG_5,469);
PESL(PWMB, PWM_WRITE_DISABLE_MAPPING_REG1,0);/*DISABLE PWM FAULTS*/
PESL(PWMB, PWM_WRITE_DISABLE_MAPPING_REG2,0);
PESL(PWMB, PWM_DEVICE, PWM_ENABLE);/*start PWM count*/
PESL(PWMB, PWM_HARDWARE_ACCELERATION,PWM_ENABLE);/*Enable writing to map & swap bits*/
PESL(PWMB, PWM_SET_SWAP,PWM_CHANNEL_01|PWM_CHANNEL_45);/*apply positive volatage to Phase B,and negative voltage to Phases A and C*/
PESL(PWMB, PWM_SET_RELOAD_FREQUENCY,PWM_RELOAD_OPPORTUNITY_16);/*Set reload to every 16 PWM periods*/
PESL(PWMB, PWM_LOAD_OK, NULL);
PESL(PWMB, PWM_OUTPUT_PAD,PWM_ENABLE);/*ENABLE PWM OUTPUT*/
for(;;) {}
}
/* END pwm_motor */
/*
** ###################################################################
**
** This file was created by UNIS Processor Expert 2.97 [03.74]
** for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -