📄 pwm12.h
字号:
/**********************************************************************/
/* Header for PWM module library functions */
/**********************************************************************/
#if defined(__dsPIC30F__)
#include <p30fxxxx.h>
#elif defined(__dsPIC33F__)
#include <p33Fxxxx.h>
#else
#error "Does not build on this target"
#endif
#ifdef _PWMIF
#ifndef __PWM_H
#define __PWM_H
/* List of SFRs for PWM */
/* This list contains the SFRs with default (POR) values to be used for configuring PWM */
/* The user can modify this based on the requirement */
#define PTCON_VALUE 0x0000
#define PTMR_VALUE 0x0000
#define PTPER_VALUE 0x0000
#define SEVTCMP_VALUE 0x0000
#define PWMCON2_VALUE 0x0000
#define DTCON1_VALUE 0x0000
#define DTCON2_VALUE 0x0000
#define FLTACON_VALUE 0x0000
#define FLTBCON_VALUE 0x0000
#define PDC1_VALUE 0x0000
#define PDC2_VALUE 0x0000
#define PDC3_VALUE 0x0000
#define PDC4_VALUE 0x0000
#ifdef _FLTBIF
#define PWMCON1_VALUE 0x00FF
#define OVDCON_VALUE 0xFF00
#else
#define PWMCON1_VALUE 0x0077
#define OVDCON_VALUE 0x3F00
#endif
/* PTCON Configuration Bit Definitions */
#define PWM_EN 0xA0FF /*Module enable*/
#define PWM_DIS 0x20FF /*Module disable*/
#define PWM_IDLE_STOP 0xA0FF /*stop in Idle mode*/
#define PWM_IDLE_CON 0x80FF /*operate in Idle mode*/
#define PWM_OP_SCALE1 0xA00F /*Out put post scaler 1:1*/
#define PWM_OP_SCALE2 0xA01F /*Out put post scaler 1:2*/
#define PWM_OP_SCALE3 0xA02F /*Out put post scaler 1:3*/
#define PWM_OP_SCALE4 0xA03F /*Out put post scaler 1:4*/
#define PWM_OP_SCALE5 0xA04F /*Out put post scaler 1:5*/
#define PWM_OP_SCALE6 0xA05F /*Out put post scaler 1:6*/
#define PWM_OP_SCALE7 0xA06F /*Out put post scaler 1:7*/
#define PWM_OP_SCALE8 0xA07F /*Out put post scaler 1:8*/
#define PWM_OP_SCALE9 0xA08F /*Out put post scaler 1:9*/
#define PWM_OP_SCALE10 0xA09F /*Out put post scaler 1:10*/
#define PWM_OP_SCALE11 0xA0AF /*Out put post scaler 1:11*/
#define PWM_OP_SCALE12 0xA0BF /*Out put post scaler 1:12*/
#define PWM_OP_SCALE13 0xA0CF /*Out put post scaler 1:13*/
#define PWM_OP_SCALE14 0xA0DF /*Out put post scaler 1:14*/
#define PWM_OP_SCALE15 0xA0EF /*Out put post scaler 1:15*/
#define PWM_OP_SCALE16 0xA0FF /*Out put post scaler 1:16*/
#define PWM_IPCLK_SCALE1 0xA0F3 /*Input pre scaler 1:1*/
#define PWM_IPCLK_SCALE4 0xA0F7 /*Input pre scaler 1:4*/
#define PWM_IPCLK_SCALE16 0xA0FB /*Input pre scaler 1:16*/
#define PWM_IPCLK_SCALE64 0xA0FF /*Input pre scaler 1:64*/
#define PWM_MOD_FREE 0xA0FC /*Mode of operation Free Running*/
#define PWM_MOD_SING 0xA0FD /*Mode of operation Single shot*/
#define PWM_MOD_UPDN 0xA0FE /*Mode of operation Up down */
#define PWM_MOD_DBL 0xA0FF /*Mode of operation Updown with double update*/
/* PWMCON1 Configuration Bit Definitions */
#define PWM_MOD3_COMP 0x0BFF /*3th channel in complimentary mode*/
#define PWM_MOD2_COMP 0x0DFF /*2th channel in complimentary mode*/
#define PWM_MOD1_COMP 0x0EFF /*1th channel in complimentary mode*/
#define PWM_MOD3_IND 0x0FFF /*3th channel in independant mode*/
#define PWM_MOD2_IND 0x0FFF /*2th channel in independant mode*/
#define PWM_MOD1_IND 0x0FFF /*1th channel in independant mode*/
#define PWM_PEN3H 0x0FFF /*H of channel 3 works as PWM*/
#define PWM_PDIS3H 0x0FBF /*H of channel 3 works as IO*/
#define PWM_PEN2H 0x0FFF /*H of channel 2 works as PWM*/
#define PWM_PDIS2H 0x0FDF /*H of channel 2 works as IO*/
#define PWM_PEN1H 0x0FFF /*H of channel 1 works as PWM*/
#define PWM_PDIS1H 0x0FEF /*H of channel 1 works as IO*/
#define PWM_PEN3L 0x0FFF /*L of channel 3 works as PWM*/
#define PWM_PDIS3L 0x0FFB /*L of channel 3 works as IO*/
#define PWM_PEN2L 0x0FFF /*L of channel 2 works as PWM*/
#define PWM_PDIS2L 0x0FFD /*L of channel 2 works as IO*/
#define PWM_PEN1L 0x0FFF /*L of channel 1 works as PWM*/
#define PWM_PDIS1L 0x0FFE /*L of channel 1 works as IO*/
/* PWMCON2 Configuration Bit Definitions */
#define PWM_SEVOPS1 0x0003 /*Special event post scaler 1:1*/
#define PWM_SEVOPS2 0x0103 /*Special event post scaler 1:2*/
#define PWM_SEVOPS3 0x0203 /*Special event post scaler 1:3*/
#define PWM_SEVOPS4 0x0303 /*Special event post scaler 1:4*/
#define PWM_SEVOPS5 0x0403 /*Special event post scaler 1:5*/
#define PWM_SEVOPS6 0x0503 /*Special event post scaler 1:6*/
#define PWM_SEVOPS7 0x0603 /*Special event post scaler 1:7*/
#define PWM_SEVOPS8 0x0703 /*Special event post scaler 1:8*/
#define PWM_SEVOPS9 0x0803 /*Special event post scaler 1:9*/
#define PWM_SEVOPS10 0x0903 /*Special event post scaler 1:10*/
#define PWM_SEVOPS11 0x0A03 /*Special event post scaler 1:11*/
#define PWM_SEVOPS12 0x0B03 /*Special event post scaler 1:12*/
#define PWM_SEVOPS13 0x0C03 /*Special event post scaler 1:13*/
#define PWM_SEVOPS14 0x0D03 /*Special event post scaler 1:14*/
#define PWM_SEVOPS15 0x0E03 /*Special event post scaler 1:15*/
#define PWM_SEVOPS16 0x0F03 /*Special event post scaler 1:16*/
#define PWM_OSYNC_PWM 0x0F03 /*over ride syncronised with PWM clk*/
#define PWM_OSYNC_TCY 0x0F01 /*over ride syncronised with sys clk*/
#define PWM_UDIS 0x0F03 /*Update of PDCs and PTPER disabled*/
#define PWM_UEN 0x0F02 /*Update of PDCs and PTPER enabled*/
/* DTCON1 Configuration Bit Definitions */
#define PWM_DTBPS8 0xFFFF /*Dead B time PreScaler = 8*/
#define PWM_DTBPS4 0xBFFF /*Dead B time PreScaler = 4*/
#define PWM_DTBPS2 0x7FFF /*Dead B time PreScaler = 2*/
#define PWM_DTBPS1 0x3FFF /*Dead B time PreScaler = 1*/
#define PWM_DTAPS8 0xFFFF /*Dead A time PreScaler = 8*/
#define PWM_DTAPS4 0xFFBF /*Dead A time PreScaler = 4*/
#define PWM_DTAPS2 0xFF7F /*Dead A time PreScaler = 2*/
#define PWM_DTAPS1 0xFF3F /*Dead A time PreScaler = 1*/
/* 6-bit dead time value bits for Dead Time Unit A */
#define PWM_DTA0 0xFFC0 /*Dead time Unit A PreScale select value */
#define PWM_DTA1 0xFFC1 /*Dead time Unit A PreScale select value */
#define PWM_DTA2 0xFFC2 /*Dead time Unit A PreScale select value */
#define PWM_DTA3 0xFFC3 /*Dead time Unit A PreScale select value */
#define PWM_DTA4 0xFFC4 /*Dead time Unit A PreScale select value */
#define PWM_DTA5 0xFFC5 /*Dead time Unit A PreScale select value */
#define PWM_DTA6 0xFFC6 /*Dead time Unit A PreScale select value */
#define PWM_DTA7 0xFFC7 /*Dead time Unit A PreScale select value */
#define PWM_DTA8 0xFFC8 /*Dead time Unit A PreScale select value */
#define PWM_DTA9 0xFFC9 /*Dead time Unit A PreScale select value */
#define PWM_DTA10 0xFFCA /*Dead time Unit A PreScale select value */
#define PWM_DTA11 0xFFCB /*Dead time Unit A PreScale select value */
#define PWM_DTA12 0xFFCC /*Dead time Unit A PreScale select value */
#define PWM_DTA13 0xFFCD /*Dead time Unit A PreScale select value */
#define PWM_DTA14 0xFFCE /*Dead time Unit A PreScale select value */
#define PWM_DTA15 0xFFCF /*Dead time Unit A PreScale select value */
#define PWM_DTA16 0xFFD0 /*Dead time Unit A PreScale select value */
#define PWM_DTA17 0xFFD1 /*Dead time Unit A PreScale select value */
#define PWM_DTA18 0xFFD2 /*Dead time Unit A PreScale select value */
#define PWM_DTA19 0xFFD3 /*Dead time Unit A PreScale select value */
#define PWM_DTA20 0xFFD4 /*Dead time Unit A PreScale select value */
#define PWM_DTA21 0xFFD5 /*Dead time Unit A PreScale select value */
#define PWM_DTA22 0xFFD6 /*Dead time Unit A PreScale select value */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -