setdcoc4pwm_gb.c

来自「Mplab C30编译器」· C语言 代码 · 共 41 行

C
41
字号
#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include <outcompare.h>

#ifdef _OCMP_V4_4
/*************************************************************************************
Function Prototype : char SetDCOC4PWM_GB(unsigned int dutycycle,unsigned int period)

Include            : outcompare.h
 
Description        : This function configures the Output Compare Secondary Duty Cycle
                     register (OCxRS) when the module is in PWM mode.

Arguments          : dutycycle - This is the duty cycle value to be stored into Output
                     Compare Main Duty Cycle register (OCxR).
                     period - This is the period stored into Secondary register (OCxRS)
 
Return Value       : Returns '1' on successful loading value else return '-1'.
 
Remarks            : The Output Compare Main and Secondary register will be
                     configured with new value only if the module is in PWM mode.
**************************************************************************************/

char SetDCOC4PWM_GB(unsigned int dutycycle,unsigned int period)
{   
    /* check if OC is in PWM Mode */
    if((OC4CON1bits.OCM & 0x06) == 0x06) 
    {
       OC4R = dutycycle;   /* assign to OCRS */
       OC4RS = period;
       return 1;
    }   
    else
       return -1;       
}

#else
#warning "Does not build on this target"
#endif

⌨️ 快捷键说明

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