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

External Interrupt have no effect on PWM?

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



Joined: 03 Apr 2010
Posts: 1

View user's profile Send private message

External Interrupt have no effect on PWM?
PostPosted: Sat Apr 03, 2010 9:27 am     Reply with quote

Hi,

My code for some simple program is as shown
Code:

#include <18F4431.h>
#use delay(clock=10000000)
#fuses NOWDT, HS, NOPROTECT, NOLVP, NOPWMPIN, HPOL_HIGH, LPOL_HIGH


#INT_EXT
void  EXT_isr(void)
{
   while(1){
      if(input(PIN_C4))
         break;
      else
         {
            output_high(PIN_D0);
            delay_ms(1000);
            output_low(PIN_D0);
            delay_ms(1000);
         }
   };
}

// interrupt function for pin INT1
#int_EXT1
void  RB_isr(void)
{
   output_high(PIN_D1);
   delay_ms(1000);
   output_low(PIN_D1);
   delay_ms(1000);
   output_high(PIN_D1);
   delay_ms(1000);
}

void main()
{
   enable_interrupts(INT_EXT); //enable interrupt function int_ext
   ext_int_edge(0,L_TO_H );      // Sets interrupt at int0 detect low to high edge
   enable_interrupts(INT_EXT1); // enable interrupt function int_ext1
   ext_int_edge(1,L_TO_H ); // sets interrupt at int1 detect low to high edge
   enable_interrupts(GLOBAL); //enable all interrupts (MUST after enable_interrupts() !!)

   set_tris_c(0xFF); //set port cinput
   set_tris_d(0x00); // set port doutput
   setup_timer_2(T2_DIV_BY_4,99,1);
   setup_ccp1(CCP_PWM);
   while(1)
   {
      set_pwm1_duty(50);

   }
}




I don't understand why the ccp pin still got the pwm signal when it is interrupted? The program still do the interrupt functions but the void main program which has pwm program is still running. The registers for pwm are not cleared during interupt? I thought interrupt will stop the void main program temporarily until the interrupt is done.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sat Apr 03, 2010 9:42 am     Reply with quote

As long as the timer is running it will generate the PWM output. It has no relation to what the CPU is doing, so interrupts that don't meddle with the timer have no effect on PWM.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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