#if defined(__PIC24F__)
#include <p24Fxxxx.h>
#endif
#include <outcompare.h>

#ifdef _OCMP1
/**********************************************************************
*    Function Name:  ReadDCOC1PWM                                     *
*    Description:    This routine reads duty cycle from Secondary     *
*                    register  in PWM mode                            *
*    Parameters:     None                                             *
*    Return Value:   unsigned int: duty cycle from Secondary register *
**********************************************************************/

unsigned int ReadDCOC1PWM()
{
    /* check if OC is in PWM Mode */

    if((OC1CONbits.OCM & 0x06) == 0x06)
    {       
        return OC1RS;   /* Output Compare Secondary Register */
    }
    else 
        return -1;
}

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