Example #1
0
void testSetDutyIsCorrect(void)
{
	const STROBESETTINGS * rtn;
	rtn = SetDuty(1);
	TEST_ASSERT_EQUAL(1, rtn->duty);
	rtn = SetDuty(0);
	TEST_ASSERT_EQUAL(1, rtn->duty);
	rtn = SetDuty(100);
	TEST_ASSERT_EQUAL(100, rtn->duty);
	rtn = SetDuty(101);
	TEST_ASSERT_EQUAL(100, rtn->duty);
}
Example #2
0
void PWM::SetFrq(uint16_t period,uint16_t prescaler)
{
	_period = period;
	_prescaler = prescaler;
	TIMxBaseInit(_period,_prescaler);
	SetDuty(_duty);

}
Example #3
0
void configurar_pwm(void){
    T2CONbits.TMR2ON=1; // timer2 prendido
    T2CONbits.TOUTPS=0; // hasta 15
    T2CONbits.T2CKPS=0; // 00=1:1 01=1:4 1x=1:16
    TRISBbits.TRISB3=0; // pwm salida
    PR2=17;//26; // periodo 30Khz
    //CCPR1L=0x01; //apagado
    CCP1CON=12;

    SetDuty( INTENSITY );
}
Example #4
0
void configurar_pwm(void){
    T2CONbits.TMR2ON=1; // timer2 prendido
    T2CONbits.TOUTPS=0; // hasta 15
    T2CONbits.T2CKPS=0; // 00=1:1 01=1:4 1x=1:16

    TRISBbits.TRISB3=0; // pwm salida
    PR2=26;//17;//26; // periodo 30Khz

    // MENOR VALOR A MAYOR VALOR
    // 78 -> 100 %
    /// 72 is the max cycle to send
    //SetDuty(7);
    CCP1CON = 12; // 12
   // CCPR1L = 0x02;
    //CCPR1L=0; //apagado
    //CCP1CON=12;
    SetDuty(15);
}