예제 #1
0
void motorSetup(void){
  
  //Setup output compare
  CloseOC1();
  CloseOC2();

  //Configure output compare using Timer 3
  ConfigIntOC1(OC_INT_OFF & OC_INT_PRIOR_5);
  ConfigIntOC2(OC_INT_OFF & OC_INT_PRIOR_5);

  PR3 = MOTOR_PWM_PERIOD;
  T3CONbits.TON = 1;
  T3CONbits.TSIDL = 1;
  T3CONbits.TGATE = 0;
  T3CONbits.TCKPS = 0b10; //prescaling 1:64
  T3CONbits.TCS = 0;
 

  OpenOC1(OC_IDLE_CON & OC_TIMER3_SRC & OC_PWM_FAULT_PIN_DISABLE , 0x00,0x00 );
  OpenOC2(OC_IDLE_CON & OC_TIMER3_SRC & OC_PWM_FAULT_PIN_DISABLE , 0x00,0x00 );

  //Write decent values to the control values
   motorSet(0.0,0.0, MOTOR_MODE_COAST);

}
예제 #2
0
파일: outputcompare.c 프로젝트: KenN7/Drone
void Initialize_OC()
{
    UnlockRP;
    _RP10R = 0b10010; //Tie OC1 to RP10 (PWM1)
    _RP11R = 0b10011; //Tie OC2 to RP11 (PWM2)
    _RP12R = 0b10100; //Tie OC3 to RP12 (PWM3)
    _RP13R = 0b10101; //Tie OC4 to RP13 (PWM4)
    LockRP;

    OpenOC1(OC_IDLE_CON & OC_TIMER3_SRC & OC_OFF, 1000, 0);
    OpenOC2(OC_IDLE_CON & OC_TIMER3_SRC & OC_OFF, 1000, 0);
    OpenOC3(OC_IDLE_CON & OC_TIMER3_SRC & OC_OFF, 1000, 0);
    OpenOC4(OC_IDLE_CON & OC_TIMER3_SRC & OC_OFF, 1000, 0); //dans l'ordre OCxRS et OCxR

    ConfigIntOC1(OC_INT_OFF & OC_INT_PRIOR_2);
    ConfigIntOC2(OC_INT_OFF & OC_INT_PRIOR_2);
    ConfigIntOC3(OC_INT_OFF & OC_INT_PRIOR_2);
    ConfigIntOC4(OC_INT_OFF & OC_INT_PRIOR_2);
}