O comando é em ponte completa com IR2110.
- Código: Selecionar todos
#include "PWM3Niveis.h"
#define MF 334 //Indice de modulação.
#define MF_2 MF/2 //Um semiciclo.
#byte CCP1CON = 0x0FBD
#byte CCPR1L = 0x0FBE
#include "tabelas.c"
#int_TIMER2
void TIMER2_isr(void)
{
static int16 k;
static int meio_mf=167;
static int indice=0;
k=(TAB_SENO[indice++]);
if(indice>166)indice=0;
set_pwm1_duty(k);
if(!--meio_mf){ //Alterna o braço da ponte de mosfets.
meio_mf=167;
if(CCP1CON &0x80)CCP1CON&=0x7F;
else CCP1CON|=0x80;
}
}
void main()
{
setup_adc_ports(AN0_TO_AN3|VSS_VDD);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DIV_BY_4,149,1);
setup_timer_3(T3_INTERNAL|T3_DIV_BY_1);
setup_ccp1(CCP_PWM_FULL_BRIDGE|CCP_PWM);
set_pwm1_duty(0); //Vai para CCPR1L e CCP1CON 4:5
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_TIMER2);
enable_interrupts(GLOBAL);
set_tris_a(3); //Duas entradas A/D.
set_tris_b(0);
set_tris_c(0);
set_tris_d(0);
set_tris_e(0);
set_pwm1_duty(0);
for(;;){
}
}