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 support@ccsinfo.com

delay problem

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



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

delay problem
PostPosted: Fri Sep 16, 2005 9:14 am     Reply with quote

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

View user's profile Send private message

Check your clock freq
PostPosted: Fri Sep 16, 2005 9:37 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 9:47 am     Reply with quote

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







PostPosted: Fri Sep 16, 2005 10:03 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 10:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 11:03 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 11:44 am     Reply with quote

Post a test program, showing all #fuses, #includes, #use statements, etc.
young



Joined: 24 Jun 2004
Posts: 285

View user's profile Send private message

PostPosted: Fri Sep 16, 2005 11:44 am     Reply with quote

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!
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