ArdyNT
Full Member level 2
I've also debug it in proteus. When ADC value is decreased below the predetermined valeu, x,y,z are equal to 0. Is this causing the pulse gone?
Any other suggestions?
Any other suggestions?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
volatile unsigned int x = 0;
volatile unsigned int y = 0;
volatile unsigned int z = 0;
if((PORTB.0 == 1) && (ldr1 <= 300)) [B]// [COLOR="#FF0000"]suppose that when this line is executed PORTB.0 = 1 so the condition is true[/COLOR][/B]
{ [B] // [COLOR="#FF0000"]in this line you may get an interrupt and set PORTB.0 = 0 so now when you return here the following line will execute although it shouldn't and can mess things up[/COLOR] [/B]
if(x > 1)
{
x = x - 1;
}
}
if(pulse_flag >= 3)
volatile unsigned int x = 0; // This never give me any pulse if I start with smaller adc value than the predetermined limit
volatile unsigned int y = 0; // If I start with high adc value (higher than the predetermined limit), everything is OK
volatile unsigned int z = 0;
volatile unsigned int x = 2;
volatile unsigned int y = 2;
volatile unsigned int z = 2;