Jump to content
Astrolupa

Delay Functions

Recommended Posts

Hi all!

 

Been testing the BoostBasic editor & compiler and it's a great product indeed. Get's even better if you buy the plugins.

I have this question... I did a sample coding for a 4Mhz 16F628A PIC, which worked right away! (Nothing too dificult to make a LED go on and off). Between the on and off cycle, I did a delay_s(1), which worked great.

Now I changed the PIC speed up to 20Mhz, and the 1 second delay is no more 1 second but just a few miliseconds. I tried to tell BB that the speed was now 20Mhz in the only place I found (clock rate under settings). Did not make a diference.

Is there any #define or alike that will instruct the compiler to be aware of the clock change? :)

 

Thank you!

 

Best regards,

Nelson

Share this post


Link to post
Share on other sites

I checked out the manual and found that the BASIC compiler uses the same prgama statements as the C compiler. So the answer is to add this line to your program.

 

#pragma CLOCK_FREQ 20000000

 

This tells the delay functions what your clock frequency is. The frequency setting that you changed with a pull down menu is for the simulator to be able to display time correctly if you use a timer plug in.

 

I hope this helps

Share this post


Link to post
Share on other sites

Hi there! Thanks for your help.

 

I've looked again at the b.b. manual, and although there's an example that uses the CLOCK_FREQ pragma, b.b. doesn't seem to know it. When compiling it gives out the following:

 

_.bas

tc_proj.bas(13): warning: unknown or invalid pragma (ignored)

 

Any ideas?

 

Best regards,

Nelson

Share this post


Link to post
Share on other sites
I've looked again at the b.b. manual, and although there's an example that uses the CLOCK_FREQ pragma, b.b. doesn't seem to know it. When compiling it gives out the following:

 

_.bas

tc_proj.bas(13): warning: unknown or invalid pragma (ignored)

 

Any ideas?

 

BoostBasic understands all pragmas supported by BoostC compiler as they use the same engine. I just verified this on a BoostBasic sample included into the installation. Here is basic code that uses the pragma and compiles. Use it as starting point:

 

#pragma CLOCK_FREQ 20000000

sub main()

end sub

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Hi Pavel! Thanks for looking. Somehow, I just pulled the pragma line to the top (I also have other pragma for eeprom and configuration bits) and it worked! Thank you very much! (Thanks to trossin too!)

 

Best regards,

Nelson Viegas

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×