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

Problem With Delay_ms(xxxx); Function

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



Joined: 05 Apr 2005
Posts: 8

View user's profile Send private message

Problem With Delay_ms(xxxx); Function
PostPosted: Fri Dec 16, 2005 2:29 pm     Reply with quote

Good afternoon PIC masters !

I am having a problem with delay_ms function. When I changed the
configuration command line #use delay(clock=xxxxx) it will effect my delay_ms(xxx) function. For example
With the #use delay(clock=4000000) configured, when I want a 1 sec delay I used command delay_ms(1000); but the delay time is only half a second instead of a full second, but when I changed my #use delay(clock=8000000) then I got the full 1 second delay as expected. The crystal oscillator Im using is 4 mhz crystal. So please ! explain to me the function relationship between these commands line (#use delay(clock=xxxx) and delay_ms(xxxx) ) when such a crystal oscillator ( 4 mhz) is used. Thank you so much for your advice
Happy Holidays
regards
Storic



Joined: 03 Dec 2005
Posts: 182
Location: Australia SA

View user's profile Send private message Send e-mail

PostPosted: Fri Dec 16, 2005 2:43 pm     Reply with quote

I dont know if this will help, is the PIC you as using have an internal OSC (8mg), if so has it been unintentialy enabled. When I first started using CCS software, at first could not get the PIC to work on the internal OSC. I had "setup_oscillator(OSC_8MHZ|OSC_NORMAL);" this line in and it did not work, I ended up taking it out and by default it worked. the PIC I was using was the 18F1320.
_________________
What has been learnt if you make the same mistake? Wink
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Dec 16, 2005 2:43 pm     Reply with quote

The value in the #use delay(clock= ) statement must match the
frequency of your crystal or oscillator (unless you're using 4x PLL mode).

Post the #include statement for your PIC, and also post the #fuses
and the #use delay statements.

Also post your compiler version.
GSFC PIC



Joined: 05 Apr 2005
Posts: 8

View user's profile Send private message

PostPosted: Tue Dec 20, 2005 2:51 pm     Reply with quote

Thanks PCM Programmer,

I removed the crystal oscillator and have it checked. It was malfunctioned, it only outputs about 5 Mhz something, I installed another crystal oscillator ( 8 mhz) and recompiled the program with #use delay(clock=8000000); this time, I got exactly 1 sec delay as expected- delay_ms(1000); I learnt one thing from this problem is even with the correct 8 mhz crystal oscillator installed, if I specify the #use delay(clock=4000000); I will get only half a second instead of a full second delay when the delay_ms(1000); statement is issued. Thanks again for coming to the rescue ...
Regards,

GSFC PIC
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