/* Sets the signal's frequency/pulse-width to the specified number of ticks. */
int pwmSetFrequencyInTicks(uint16_t ticks)
/* Sets the signal's frequency/pulse-width to the specified number of ticks. */
int pwmSetFrequencyInTicks(uint16_t ticks)
{
  if (ticks < 1)
  {
    return -1;
  }
  TMR_TMR16B1MR3 = (pwmPulseWidth = ticks - 1);
  TMR_TMR16B1MR0 = (pwmPulseWidth * (100 - pwmDutyCycle)) / 100;
  return 0;  
}