samuel.sam77
Member
hi am beginner of pic programmer i need a code for pwm smooth start for my smbs ..here i am using pic 16f690 .i enabled eccp pwm ..i here i show the code is working halfbridge mode
so i need when i switch on the pulse to start from 0 to loaded duty cycle value ..this is my code using ccs c complier
#USE DELAY (CLOCK=8000000)
#byte PWM1CON=0x1C
#byte Eccpas = 0x1D
#define CCP_SHUTDOWN_MODE (CCP_SHUTDOWN_ON_INT0 | \
CCP_SHUTDOWN_AC_L | \
CCP_SHUTDOWN_BD_L | \
CCP_SHUTDOWN_RESTART)
#byte ccp1con=0x17
void main()
{
int i,j,k,n;
DISABLE_INTERRUPTS(GLOBAL);
setup_adc_ports(sAN10|sAN11|VSS_VDD);
setup_adc( ADC_CLOCK_INTERNAL );
SETUP_CCP1(CCP_PWM_HALF_BRIDGE|CCP_PWM_H_H|CCP_SHUTDOWN_MODE) ;
set_tris_c(0xc0);
while(1)
{
set_adc_channel( 10 );
delay_ms(10);
i=read_adc();
delay_ms(100);
j=i/42.50+(58.5);
k=(j/1.8);
delay_ms(10);
SETUP_TIMER_2(T2_DIV_BY_1,j,1);
Pwm1con=0x04;
set_pwm1_duty(k);
}
}
also thre is a shut down command one is interrupt and another one is comparator any help me the hardware connection for comparator which pin ref and which is input
help me
so i need when i switch on the pulse to start from 0 to loaded duty cycle value ..this is my code using ccs c complier
#USE DELAY (CLOCK=8000000)
#byte PWM1CON=0x1C
#byte Eccpas = 0x1D
#define CCP_SHUTDOWN_MODE (CCP_SHUTDOWN_ON_INT0 | \
CCP_SHUTDOWN_AC_L | \
CCP_SHUTDOWN_BD_L | \
CCP_SHUTDOWN_RESTART)
#byte ccp1con=0x17
void main()
{
int i,j,k,n;
DISABLE_INTERRUPTS(GLOBAL);
setup_adc_ports(sAN10|sAN11|VSS_VDD);
setup_adc( ADC_CLOCK_INTERNAL );
SETUP_CCP1(CCP_PWM_HALF_BRIDGE|CCP_PWM_H_H|CCP_SHUTDOWN_MODE) ;
set_tris_c(0xc0);
while(1)
{
set_adc_channel( 10 );
delay_ms(10);
i=read_adc();
delay_ms(100);
j=i/42.50+(58.5);
k=(j/1.8);
delay_ms(10);
SETUP_TIMER_2(T2_DIV_BY_1,j,1);
Pwm1con=0x04;
set_pwm1_duty(k);
}
}
also thre is a shut down command one is interrupt and another one is comparator any help me the hardware connection for comparator which pin ref and which is input
help me