📄 setdcoc1pwm.c
字号:
#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include <outcompare.h>
#ifdef _OCMP1
/*************************************************************************************
Function Prototype : char SetDCOC1PWM(unsigned int dutycycle)
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 Secondary Duty Cycle register (OCxRS).
Return Value : Returns '1' on successful loading value else return '-1'.
Remarks : The Output Compare Secondary Duty Cycle register (OCxRS) will be
configured with new value only if the module is in PWM mode.
**************************************************************************************/
char SetDCOC1PWM(unsigned int dutycycle)
{
/* check if OC is in PWM Mode */
if((OC1CONbits.OCM & 0x06) == 0x06)
{
OC1RS = dutycycle; /* assign to OCRS */
return 1;
}
else
return -1;
}
#else
#warning "Does not build on this target"
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -