⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pwm.h

📁 Microchip的官方PIC24H系列16位单片机的外设源程序库。
💻 H
📖 第 1 页 / 共 3 页
字号:

#define PWM_FLTA_INT_PR0	0xFF8F	/* FaultA interrupt priority 0*/
#define PWM_FLTA_INT_PR1	0xFF9F	/* FaultA interrupt priority 1*/
#define PWM_FLTA_INT_PR2	0xFFAF	/* FaultA interrupt priority 2*/
#define PWM_FLTA_INT_PR3	0xFFBF	/* FaultA interrupt priority 3*/
#define PWM_FLTA_INT_PR4	0xFFCF	/* FaultA interrupt priority 4*/
#define PWM_FLTA_INT_PR5	0xFFDF	/* FaultA interrupt priority 5*/
#define PWM_FLTA_INT_PR6	0xFFEF	/* FaultA interrupt priority 6*/
#define PWM_FLTA_INT_PR7	0xFFFF	/* FaultA interrupt priority 7*/

/* FLTACON Register */

#define PWM_OVA3H_ACTIVE        0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVA2H_ACTIVE        0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVA1H_ACTIVE        0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVA3L_ACTIVE        0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVA2L_ACTIVE        0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVA1L_ACTIVE        0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVA3H_INACTIVE      0xDFFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVA2H_INACTIVE      0xF7FF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVA1H_INACTIVE      0xFDFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVA3L_INACTIVE      0xEFFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVA2L_INACTIVE      0xFBFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVA1L_INACTIVE      0xFEFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/

#define PWM_FLTA_MODE_CYCLE     0xFFFF  /* The Fault A input pin functions in the cycle-by-cycle limit mode.*/
#define PWM_FLTA_MODE_LATCH	0xFF7F  /* The Fault A input pin latches all control pins to the programmed states.*/
#define PWM_FLTA3_EN		0xFFFF  /* PWM3H/PWM3L pin pair is controlled by Fault Input A.*/
#define PWM_FLTA2_EN		0xFFFF  /* PWM2H/PWM2L pin pair is controlled by Fault Input A.*/
#define PWM_FLTA1_EN		0xFFFF  /* PWM1H/PWM1L pin pair is controlled by Fault Input A.*/
#define PWM_FLTA3_DIS		0xFFFB  /* PWM3H/PWM3L pin pair is not controlled by Fault Input A.*/
#define PWM_FLTA2_DIS		0xFFFD  /* PWM2H/PWM2L pin pair is not controlled by Fault Input A.*/
#define PWM_FLTA1_DIS		0xFFFE  /* PWM1H/PWM1L pin pair is not controlled by Fault Input A.*/

/* Macros to  Enable/Disable interrupts and set Interrupt priority of PWM */
#define EnableIntMCPWM                    asm("BSET IEC2,#7")
#define DisableIntMCPWM                   asm("BCLR IEC2,#7")
#define SetPriorityIntMCPWM(priority)     (IPC9bits.PWMIP = priority)

#define EnableIntFLTA                    asm("BSET IEC2,#11")
#define DisableIntFLTA                   asm("BCLR IEC2,#11")
#define SetPriorityIntFLTA(priority)     (IPC10bits.FLTAIP = priority)


/* PWM4 is supported in dsPIC30F6010 devices */

#if defined(__dsPIC30F6010__) 

/* PWMCON1 Configuration Bit Definitions */

#define PWM_MOD4_COMP          0x07FF  /*4th channel in complimentary mode*/
#define PWM_MOD4_IND           0x0FFF  /*4th channel in independant mode*/

#define PWM_PEN4H              0x0FFF  /*H of channel 4 works as PWM*/
#define PWM_PDIS4H             0x0F7F  /*H of channel 4 works as IO*/

#define PWM_PEN4L              0x0FFF  /*L of channel 4 works as PWM*/
#define PWM_PDIS4L             0x0FF7  /*L of channel 4 works as IO*/

/* DTCON2 Configuration Bit Definitions */
#define PWM_DTS4A_UB           0x00FF  /*Dead time for channel 4 to get Active controlled by unit B*/
#define PWM_DTS4I_UB           0x00FF  /*Dead time for channel 4 to get Inactive controlled by unit B*/
#define PWM_DTS4A_UA           0x007F  /*Dead time for channel 4 to get Active controlled by unit A*/
#define PWM_DTS4I_UA           0x00BF  /*Dead time for channel 4 to get Inactive controlled by unit A*/

/* OVDCON Configuration Bit Definitions */
#define PWM_GEN_4H             0xFFFF  /*controlled by the PWM generator.*/
#define PWM_GEN_4L             0xFFFF  /*controlled by the PWM generator.*/

#define PWM_POUT_4H            0x7FFF  /*controlled by the value in the corresponding POUT bit.*/
#define PWM_POUT_4L            0xBFFF  /*controlled by the value in the corresponding POUT bit.*/

#define PWM_POUT4H_ACT         0xFFFF  /*I/O pin is driven ACTIVE when the corresponding POVDxx bit is cleared.*/
#define PWM_POUT4H_INACT       0xFF7F  /*I/O pin is driven INACTIVE when the corresponding POVDxx bit is cleared.*/

#define PWM_POUT4L_ACT         0xFFFF   /*I/O pin is driven ACTIVE when the corresponding POVDxx bit is cleared.*/
#define PWM_POUT4L_INACT       0xFFBF  /*I/O pin is driven INACTIVE when the corresponding POVDxx bit is cleared.*/

/* FLTACON Register  */

#define PWM_OVA4H_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVA4L_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVA4H_INACTIVE     0x7FFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVA4L_INACTIVE     0xBFFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_FLTA4_EN	       0xFFFF  /* PWM4H/PWM4L pin pair is controlled by Fault Input A.*/
#define PWM_FLTA4_DIS	       0xFFF7  /* PWM4H/PWM4L pin pair is not controlled by Fault Input A.*/

/* Enable/Disable FaultB Interrupt */
#define PWM_FLTB_EN_INT	       0xFFFF	/*Enable Fault B Interrupt */
#define PWM_FLTB_DIS_INT       0xF7FF	/*Disable Fault B Interrupt */

/* Setting the priority of PWM FaultB interrupt */

#define PWM_FLTB_INT_PR0       0xF8FF	/* FaultB interrupt priority 0*/
#define PWM_FLTB_INT_PR1       0xF9FF	/* FaultB interrupt priority 1*/
#define PWM_FLTB_INT_PR2       0xFAFF	/* FaultB interrupt priority 2*/
#define PWM_FLTB_INT_PR3       0xFBFF	/* FaultB interrupt priority 3*/
#define PWM_FLTB_INT_PR4       0xFCFF	/* FaultB interrupt priority 4*/
#define PWM_FLTB_INT_PR5       0xFDFF	/* FaultB interrupt priority 5*/
#define PWM_FLTB_INT_PR6       0xFEFF	/* FaultB interrupt priority 6*/
#define PWM_FLTB_INT_PR7       0xFFFF	/* FaultB interrupt priority 7*/

/* FLTBCON Register  */
#define PWM_OVB4H_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVB4L_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVB3H_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVB2H_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVB1H_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVB3L_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVB2L_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVB1L_ACTIVE       0xFFFF  /*The PWM output pin is driven ACTIVE on an external fault input event.*/
#define PWM_OVB4H_INACTIVE     0x7FFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVB3H_INACTIVE     0xDFFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVB2H_INACTIVE     0xF7FF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVB1H_INACTIVE     0xFDFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVB4L_INACTIVE     0xBFFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVB3L_INACTIVE     0xEFFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVB2L_INACTIVE     0xFBFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_OVB1L_INACTIVE     0xFEFF  /*The PWM output pin is driven INACTIVE on an external fault input event.*/
#define PWM_FLTB_MODE_CYCLE    0xFFFF  /* The Fault B input pin functions in the cycle-by-cycle limit mode.*/
#define PWM_FLTB_MODE_LATCH    0xFF7F  /* The Fault B input pin latches all control pins to the programmed states.*/

#define PWM_FLTB4_EN	       0xFFFF  /* PWM4H/PWM4L pin pair is controlled by Fault Input B.*/
#define PWM_FLTB3_EN	       0xFFFF  /* PWM3H/PWM3L pin pair is controlled by Fault Input B.*/
#define PWM_FLTB2_EN	       0xFFFF  /* PWM2H/PWM2L pin pair is controlled by Fault Input B.*/
#define PWM_FLTB1_EN	       0xFFFF  /* PWM1H/PWM1L pin pair is controlled by Fault Input B.*/
#define PWM_FLTB4_DIS	       0xFFF7  /* PWM4H/PWM4L pin pair is not controlled by Fault Input B.*/
#define PWM_FLTB3_DIS	       0xFFFB  /* PWM3H/PWM3L pin pair is not controlled by Fault Input B.*/
#define PWM_FLTB2_DIS	       0xFFFD  /* PWM2H/PWM2L pin pair is not controlled by Fault Input B.*/
#define PWM_FLTB1_DIS	       0xFFFE  /* PWM1H/PWM1L pin pair is not controlled by Fault Input B.*/

/* Macros to  Enable/Disable interrupts and set Interrupt priority of PWM */

#define EnableIntFLTB                    asm("BSET IEC2,#12")
#define DisableIntFLTB                   asm("BCLR IEC2,#12")
#define SetPriorityIntFLTB(priority)     (IPC11bits.FLTBIP = priority)

#endif
/***************Function prototypes*****************************/
void CloseMCPWM(void) __attribute__ ((section (".libperi")));

void ConfigIntMCPWM(unsigned int config) __attribute__ ((section (".libperi")));

void OpenMCPWM(unsigned int period, unsigned int sptime,unsigned int
               config1, unsigned int config2, unsigned int config3) __attribute__ ((section (".libperi")));

void OverrideMCPWM(unsigned int config) __attribute__ ((section (".libperi")));

void SetDCMCPWM(unsigned int dutycyclereg, unsigned int dutycycle, 
                char updatedisable) __attribute__ ((section (".libperi")));

void SetMCPWMDeadTimeGeneration(unsigned int config) __attribute__ ((section (".libperi")));

void SetMCPWMFaultA(unsigned int config) __attribute__ ((section (".libperi")));

#if defined(__dsPIC30F6010__)

void SetMCPWMDeadTimeAssignment(unsigned int config) __attribute__ ((section (".libperi")));

void SetMCPWMFaultB(unsigned int config) __attribute__ ((section (".libperi")));

#endif

#endif

#endif /*__PWM_H */

⌨️ 快捷键说明

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