Giter Site home page Giter Site logo

The WDT issue. about lgt8fx HOT 11 CLOSED

LaZsolt avatar LaZsolt commented on May 25, 2024
The WDT issue.

from lgt8fx.

Comments (11)

LaZsolt avatar LaZsolt commented on May 25, 2024 1

a flag can be set for a user can see if the chip is faulty.

I changed my mind. It is not necessary to set a signal, but restore WDT interrupt capability by software.

If this function below inserted into main.cpp the WDT interrupt capability will be restored. The only difference is the WDT interrupt + reset function will be longer about 64 ms.
This process not tested on 328D yet. I will test it on 328D today.

#if defined(__LGT8FX8P__)
void softRepairedWdtIsr(void) __attribute__ ((naked)) __attribute__ ((used)) __attribute__ ((section (".init0")));
void softRepairedWdtIsr(void)
{
    uint8_t tmpwsr = WDTCSR;
    if (tmpwsr & ( (1 << WDIF))) {
        if (tmpwsr & ( (1 << WDIE))) {
            tmpwsr &= ~(1 << WDIE);
            WDTCSR = tmpwsr;
            WDTCSR = tmpwsr | (1 << WDIF);
            // WDT interrupt
            __asm__ __volatile__ ("jmp __vector_6 \n");
        }
        // WDT interrupt then system reset.
        __asm__ __volatile__ ("call __vector_6 \n");
        WDTCSR = (1 << WDE) | (1 << WDCE);
        WDTCSR = (1 << WDE);
        while(1);
    }
}
#endif

from lgt8fx.

LaZsolt avatar LaZsolt commented on May 25, 2024 1

Done. I finished the better watchdog timer library. Pls try it: https://github.com/dbuezas/lgt8fx/tree/Better_wdt_lib/lgt8f/libraries/WDT

from lgt8fx.

LaZsolt avatar LaZsolt commented on May 25, 2024 1

Okay, but a bit later.
I would like to finish the LowPower library and after that I will open PR.

from lgt8fx.

dbuezas avatar dbuezas commented on May 25, 2024

That's clever! We can fix it in the core.

from lgt8fx.

wollewald avatar wollewald commented on May 25, 2024

Sounds good! Thank you for following up on this topic.

from lgt8fx.

LaZsolt avatar LaZsolt commented on May 25, 2024

If this function below inserted into main.cpp the WDT interrupt capability will be restored.

It is better to include it in WDT.h because there will be no wasted FLASH space when the Watchdog timer not in use.

from lgt8fx.

LaZsolt avatar LaZsolt commented on May 25, 2024

Ohhh. Must save and restore SREG before jumping to WDT ISR ( __vector_6 ).

from lgt8fx.

LaZsolt avatar LaZsolt commented on May 25, 2024

And some registers. But because I don't know which registers the compiler put there, all of the above must be written in assembler language.

from lgt8fx.

wollewald avatar wollewald commented on May 25, 2024

@LaZsolt, you are a hero! I tried the wdt_interrupt sketch and it's working perfect.

In particular, I was missing the ISR to be able to perform actions before the reset. For example, that could be saving data to the EEPROM which can help to find the reason for the WDT reset. wdt_ienable() does not trigger a reset, but if wdt_ienable(WTO_4S) in line 34 is changed to wdt_enable(WTO_4S); I get exactly what I wanted (ISR + reset).

Screenshot 2023-04-15 120103

Great thanks - I will modify this section my blog post.

from lgt8fx.

dbuezas avatar dbuezas commented on May 25, 2024

That's great!
@LaZsolt would you open a PR so it gets auto deployed after we merge?

from lgt8fx.

LaZsolt avatar LaZsolt commented on May 25, 2024

This issue is solved with is PR: #274

from lgt8fx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.