vishnuk
Joined: 08 Aug 2020 Posts: 2
|
PIC18F4550 |
Posted: Tue Apr 05, 2022 1:25 am |
|
|
Sir,
I am using the Half-bridge code for CCP1.
How can I add dead time between each switching eg 10n-sec?
Code: |
#include <18F4550.h>
#device ADC = 10
#fuses NOMCLR ,HS
#use delay(clock=8M)
INT i,j;
void main()
{
char duty_cycle[100]={0,1,1,2,3,4,5,6,8,10,11,14,16,18,21,23,26,29,32,35,38,41,44,47,50,53,
56,59,62,65,68,71,74,77,79,82,84,86,89,90,92,94,95,96,98,98,99,100,
100,100,100,100,99,98,98,96,95,94,92,90,89,86,84,82,79,77,74,71,68,
65,62,59,56,53,50,47,44,41,38,35,32,29,26,23,21,18,16,14,11,10,8,6,5,
4,3,2,2,2,1,0};
setup_timer_2(T2_DIV_BY_1,100,1);
setup_ccp1(CCP_PWM | CCP_PWM_HALF_BRIDGE);
while(true)
{
if (interrupt_active(INT_TIMER2))
{
clear_interrupt(INT_TIMER2);
i++;
if(i==100) {i=0; j++; if(j==2) j=0;}
}
set_pwm1_duty(duty_cycle[i]);
}
}
|
|
|