View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
delay problem |
Posted: Fri Sep 16, 2005 9:14 am |
|
|
I build a program which capture low to high pulse signals from int pin, it works fine because it did catch every pulse signal, however, when after I received the inerrupt signal, I want to sendout another pulses (sound not necessary, but thast is what request here), when I check from the scope, I found there is several hundreds us delay between my input signal and the pulse signal I send inside the interrupt routine, why there is such big delay? I do not think if(input(PIN_A1)) and output_low(PIN_A5) will cause
such a big delay between this input and output signals?
I am using a internal 4mhz ocsilator
here is part of tyhe program
Code: | #int_ext
void ext_isr()
{
if(input(PIN_A1))
{
output_low(PIN_A5);
output_high(PIN_C0);
delay_us(200);
output_low(PIN_C0);
delay_us(200);
}
|
|
|
|
croc4
Joined: 02 Sep 2005 Posts: 10
|
Check your clock freq |
Posted: Fri Sep 16, 2005 9:37 am |
|
|
you may have an issue with your osc freq and the way you declare your delay (#USE delay(xxxxxx)), if this number is different from the actual osc speed I have seen it skew the delay_us/ms commands quite a bit. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Sep 16, 2005 9:47 am |
|
|
thank you for the response. what I defined is
#fuses INTRC_IO, BROWNOUT,NOWDT,NOPROTECT,MCLR,PUT
#use delay(clock=4000000)
clock should not be a problem as you pointed out. |
|
|
Ttelmah Guest
|
|
Posted: Fri Sep 16, 2005 10:03 am |
|
|
What chip?. What compiler version?.
There were bugs, until quite recently, with relying on the compiler to automatically set the oscillator speed correctly.
Setup_oscillator(OSC_4MHZ|OSC_INTRC);
will avoid this if it is causing the problem. Worth a try.
Best Wishes |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Sep 16, 2005 10:39 am |
|
|
i am using 16f630 chip and the compiler is 3.202. I put the Setup_oscillator(OSC_4MHZ|OSC_INTRC); but the compiler could not recognize it. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Sep 16, 2005 11:03 am |
|
|
if clock is wrong, the delay_us(200) should be wrong also, however, I did not see delay_us(200) wrong. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Sep 16, 2005 11:44 am |
|
|
Post a test program, showing all #fuses, #includes, #use statements, etc. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Fri Sep 16, 2005 11:44 am |
|
|
it is my fault, there is two signal. I took the wrong one. sorry, but it is a good point to learn about the possible clock problem.
Thank you Ttelmah and croc4! |
|
|
|