CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with pulse steering on 16F690 while doing if-else

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mukeshp11



Joined: 10 Dec 2008
Posts: 15

View user's profile Send private message Send e-mail Yahoo Messenger

Problem with pulse steering on 16F690 while doing if-else
PostPosted: Mon Sep 19, 2011 6:06 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group