Jump to content

Recommended Posts

Hi guys,


how come that if I change the clock rate in the SourceBoost IDE simulator and then run the code with some delay_ms() functions, the "ticks counter" in the bottom of the screen still gives me the same number? For example I've got delay_ms(40) and I still get cca 156k ticks after that no matter how big the clock rate is... could you give me a hint why is that so?


Thanks so much,



Share this post

Link to post
Share on other sites



What exactly do you mean by changing the clock rate in the IDE? Is it the settings menu?


In order to have an acurate simulation you have to keep the following items in sync.

- PIC configuration and oscillator options

- #pragma CLOCK_FREQ xxxxxxx

- IDE settings/clock rate menu


The "delay_ms()" macro generates code based on the CLOCK_FREQ pragma.

The IDE settings/clock rate is used to inform the simulator calculator so it can compute run time and is also used by the plug-in system.


And don't mix "time" with "instructions", whatever clock rate you use, the number of executed instructions betwen 2 breakpoints will allways be the same, only the calculated time lapse will change.




Best regards


Edited by JorgeF

Share this post

Link to post
Share on other sites

Thank you for your answer,


now I realize I may have put this topic in incorrct thread, because what I'm trying to do is develop a plug-in for the SB IDE, so I was thinking I only use the Settings Clock Rate. The particular problem is I want to get the plugin to work after approximate time of 15ms. In the plugin syste there's a callback function which is called by every clock tick of the simulator (clk is the current count of ticks provided by the simulator itself), so I was just thinking putting something like

if (clk < clockRate*15/1000) {
// dont do anything

// code after 15ms

will do the thing, but as you're saying when using delay_ms in the code for testing of the plugin will always look at the pragma.



Share this post

Link to post
Share on other sites

Try to add #pragma CLOCK_FREQ into the project code with the number that matches the clock rate set in IDE and rebuild your project.




Share this post

Link to post
Share on other sites

Yes, that's the only reasonable thing to do, I was just confused by that setting the clock rate externaly won't make it alone :)


Thanks anyways, now it works as it should have



Share this post

Link to post
Share on other sites

Your content will need to be approved by a moderator

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 emoji 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.