kolopipo
Joined: 03 Apr 2010 Posts: 1
|
External Interrupt have no effect on PWM? |
Posted: Sat Apr 03, 2010 9:27 am |
|
|
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. |
|