Comments (11)
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.
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.
Okay, but a bit later.
I would like to finish the LowPower library and after that I will open PR.
from lgt8fx.
That's clever! We can fix it in the core.
from lgt8fx.
Sounds good! Thank you for following up on this topic.
from lgt8fx.
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.
Ohhh. Must save and restore SREG before jumping to WDT ISR ( __vector_6 ).
from lgt8fx.
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.
@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).
Great thanks - I will modify this section my blog post.
from lgt8fx.
That's great!
@LaZsolt would you open a PR so it gets auto deployed after we merge?
from lgt8fx.
This issue is solved with is PR: #274
from lgt8fx.
Related Issues (20)
- StLink v2 HOT 1
- NO SSL for json file HOT 7
- EEPROM library on logging principle (from STM32) HOT 10
- Problems with burning the bootloader HOT 14
- Cannot compile HOT 6
- [SOLUTION] Compilation error
- lgt8fx - Boards Manager Menu error / quirk - for Internal 16MHz / 32MHz HOT 27
- Lgt8fx - ADC analogRead() is wrong - it only returns back 10bit - need to load manually ADCH + ADCL to get 12bit value HOT 2
- FastIO will not accept defined constants HOT 3
- Internal clock speeds less than 32MHz no longer available since version 2.0.3. HOT 3
- voltage and current on pins when MCU in LowPower.deepSleep2 HOT 1
- standbyExternalInterrupt example does not consistently work HOT 1
- I am using emonlib with arduino then it is working HOT 2
- LGT8F328P program size HOT 6
- WDT clock source problem HOT 6
- E2PROM HOT 8
- How to burn booloader HOT 2
- Won't flash using IDE 2.2.1 HOT 38
- DSP1 not working correctly with example code from lgt_LowPower library HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lgt8fx.