Jump to content


Photo

Delay Functions


4 replies to this topic

#1 Astrolupa

Astrolupa

    Newbrie

  • Members
  • 3 posts

Posted 11 January 2008 - 05:37 PM

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

#2 trossin

trossin

    Super Enthusiast

  • Moderator
  • PipPipPip
  • 243 posts
  • Gender:Male
  • Location:Colorado

Posted 14 January 2008 - 06:43 PM

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

#3 Astrolupa

Astrolupa

    Newbrie

  • Members
  • 3 posts

Posted 22 January 2008 - 06:18 PM

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

#4 Pavel

Pavel

    Super Maniac

  • Administrators
  • PipPipPipPipPip
  • 1,441 posts
  • Gender:Male
  • Location:Melbourne, Australia

Posted 22 January 2008 - 10:30 PM

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

#5 Astrolupa

Astrolupa

    Newbrie

  • Members
  • 3 posts

Posted 31 January 2008 - 11:03 AM

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



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users