mukeshp11
Joined: 10 Dec 2008 Posts: 15
|
Problem with pulse steering on 16F690 while doing if-else |
Posted: Mon Sep 19, 2011 6:06 am |
|
|
Hello,
Kindly help with the following code:-
Code: |
void main()
{
//set_tris_c(0x00);
//setup_oscillator(OSC_NORMAL );
set_tris_b(0xff);
setup_timer_2(T2_DIV_BY_1, 255, 1); //19.53 khz switching frequency =51us sampling time
clear_interrupt(INT_TIMER2);
enable_interrupts(INT_TIMER2);
//enable_interrupts(INT_TIMER0);
enable_interrupts(GLOBAL); ////enable_interrupts(GLOBAL);
//set_pwm1_duty(235);
output_low(P1A);
output_low(P1B);
output_low(P1C);
output_low(P1D);
while(1)
{
}
}
#int_timer2 //timer 2 over flow
void timer2_isr(void)
{
output_high(PIN_C7);
duty_cycle = 200;
if(!input(PIN_B6) && !input(PIN_B4))
{
setup_CCP1(CCP_PWM_H_H | CCP_PULSE_STEERING_A);
output_high(P1D);
output_low(P1C);
output_high(P1B);
}
else
{
output_low(P1D);
output_low(P1C);
output_low(P1B);
output_low(P1A);
} |
In the above code In my TIMER 2whenever my condition i.e. B6 and B4 are 0. PWM is coming on portA. When in running condition if i change B6 and B4 to other value i.e if condition is false then also PWM on port A doesnt disappears. But if I restart the whole system then the PWM disappears.
i.e in running condition if I change the condition of IF loop to false state, my else loop is not executed and PWM remains on port A and if I switch Off and On again the system then only it enters in else condition.
My timer 2 is working well that i checked.
Kindly help
Regards
Mukesh |
|