Connect with us

Crashing after 145 seconds

Discussion in 'Microcontrollers, Programming and IoT' started by LordSputnik, Jun 6, 2012.

Scroll to continue with content
  1. CocaCola

    CocaCola

    3,635
    5
    Apr 7, 2012
    I'm not quite sure where you are heading, you asked why the need to clear the watchdog vs just disabling it...

    The answer is simple, if it's enabled it needs to be cleared periodically or else it will time out and reset that is the way it works as the native level regardless of what language you use to program... If you disable it well, then it's disabled...

    I don't find the compiler injecting the clears to be an issue, if I have the WDT enabled and want to have the micro 'pause' for a few seconds the WDT is going to have to be cleared during that time no matter what...

    I personally like the fact that I don't have to make a delay loop that will constantly clear the WDT as the delay counts down, when I can simply type two words PAUSE 5000 and know the compiler is going to take care of the rest while it delays for 5 seconds... If dividing an overall delay into smaller parts inside a FOR/NEXT loop and putting in WDT clears inside that loop works better for you go for it, I could do the same as well but I find the single line much easier...
     
  2. gorgon

    gorgon

    603
    24
    Jun 6, 2011
    Even if you run a compiled BASIC program, you'll necessarily run on top/as part of an inbuilt kernel, almost like an operating system.

    I did not say that you can't compare it to a compiled C or assembler program, I said a barebone C or assembler program. Where your program has total control of the hardware.

    But, we are really nitpicking here, the problem was the watchdog and the use of that.

    TOK ;)
     
  3. CocaCola

    CocaCola

    3,635
    5
    Apr 7, 2012
    What you describe is the way it 'used' to be when BASIC was an interpreted language and still is in some cases, but not all... I do remember the days of loading a BASIC interpreter or plugging in a BASIC module/cartridge to run your BASIC programs and even know that some BASIC languages like Visual Basic rely on a bunch of support files that need to accompany the compiled code to run... But, that is no the case with most current BASIC compilers for micros any longer... PicBASIC Pro compiles native code the same way a C compiler compiles to native code the compiled code is not running on top of anything else... Just like most C compilers there is no underlying 'inbuilt kernel' in the final code a BASIC compiler outputs, it's stand alone native code...

    I have to asked do you have any experience with modern BASIC compilers like PicBASIC Pro or are you basing your assumptions on past experience with other systems that doesn't necessarily apply any longer or in this case?

    Even if it's 'barebone' C isn't not a native language of the micro, it's simply a different high level language that needs to be translated to raw code for the micro to run.. To say that a C program has total control of the hardware while another language doesn't is really putting on your blinders to the facts... I can easily do inline assembly (for anythign that might not be supported in PBP) in any PicBasic Pro program giving me total control but one has to asked when and at what level is this control necessary in any given case ... I can have full control of the hardware just like C if I choose do it that way, but for many things it's simply not worth the hassle to deal with and I personally prefer not having to deal with it...
     
    Last edited: Jun 11, 2012
  4. gorgon

    gorgon

    603
    24
    Jun 6, 2011
    I mostly rely on your statement in the first quote, and are interpolating from there. And no, I've not used the modern BASIC compilers. From tests I have read though, I've had the impression that even compiled BASIC has a speed loss, compared to other languages. This again imply a background code overhead, and some sort of kernel code.

    We are more or less down to semantics and 'my dad is stronger than yours...' comments, and again, this is about automatic watchdog insertions or not.

    In my proffesional world this is a real safety issue, and using a system that automatically inserts 'Watchdog feeds', can be a pending disaster.
    For a DIY programmer it's seemingly of little importance, but it's depending on where you finally put your design to work. If you need to walk 2 days to reset it, I would have included the good old watchdog in my design.

    TOK ;)
     
  5. CocaCola

    CocaCola

    3,635
    5
    Apr 7, 2012
    Not, my words it's from the PBP manual that I attached as an image of, it's a default setting but it's not a hard coded setting it can be disabled if one chooses, and likely would if someone really wanted to implement a tighter watchdog or was concerned about the watchdog implementation...

    As always you will find code examples that both substantiate and disprove that, it really depends on code... That includes the original code, sloppy code in is going to get sloppy code out, and I believe this will account for a vast majority of the speed difference, the programming mindset of the average C programer is different then that of the average BASIC programmer...

    What is interesting is that they claim "The code that PBP generates is efficient and optimized. Execution speed rivals that of any C compiler (for PIC MCUs) on the market."

    Their claim not mine, but I'm sure they have examples to substantiate it and I'm sure there are those that have examples that cry foul... Either way I'm willing to put my money on the fact that the compiled code is every bit in the same ballpark as most if not all C compilers... Today's BASIC compilers have come a long way, they are true compilers and no longer interpreters...

    More so just a different conversion to the native code, I'm sure you are well aware that every compiler translates and optimizes to different levels even for the same exact code... There is no direct path from any high level language to a low level one, there are going to be proprietary paths taken by any product to accomplish the task, some better than others... Thus the execution time between two C compilers is going to vary just like it will between a C and BASIC compiler... How well the code was originally written obviously plays a huge factor as well, as does if it was written with optimization for a particular language...

    And in such cases you simply disable the default feature...

    DEFINE NO_CLRWDT

    No more automated clearing...
     
    Last edited: Jun 11, 2012
  6. jackorocko

    jackorocko

    1,284
    1
    Apr 4, 2010
    Because you made it sound like that it is the compilers job to make sure the watchdog timer doesn't reset the uC...

    ;) We get it, you're a 'basic' guy
     
    Last edited: Jun 11, 2012
  7. CocaCola

    CocaCola

    3,635
    5
    Apr 7, 2012
    No it's job but I won't complain if the compiler makes my life easier by automating a task that is necessary...

    It's my preferred language for micros yes, probably not yours :p
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-