Esempio n. 1
0
void main(void)
{
	//initialize portc
	PORTC = 0x00;
	TRISC = 0x00;
	
	//initialize pwm
	PWM_Init(5000); //initialize pwm at 5khz
	PWM1_Duty(0); //set initial duty cycle at 0 on pin RC2
	PWM2_Duty(0); 
	
	//start pwm
	PWM1_Start();
    PWM2_Start();
	
	
	while (1)
	{
	
		for (int i=0; i<1023; i+=4)
		{
			PWM1_duty();
			PWM2_Duty(1023-i);
			__delay_ms(2);
		}
	
	
	}


}
Esempio n. 2
0
void blink ()
{
    unsigned int t;
    PWM1_Duty(24000);
    while(1)
    {
        LATAbits.LATA4 = 0;
        LATAbits.LATA0 = 1;
        LATBbits.LATB2 = 1;
        t = timer_start();
        while (!timer_timeout(t, 10000000));
        LATAbits.LATA4 = 1;
        LATAbits.LATA0 = 0;
        LATBbits.LATB2 = 0;
        t = timer_start();
        while (!timer_timeout(t, 10000000));
    }   
}