Hello All! I want to reset 89v51RD2 in less than 1 ms after external Interrupt.
i wrote this code
void external(void) interrupt 0 // External INT0 ISR { EA = 0; // interrupt disable WDRE=1; SWDT=1; while(1); // wait till reset }
but it didn't worked. Please help
According to Datasheet:
To protect the system against software deadlock, the user software must refresh the WDT within a user-defined time period. If the software fails to do this periodical refresh, an internal hardware reset will be initiated if enabled (WDRE = 1). The software can be designed such that the WDT times out if the program does not work properly.
The WDT in the device uses the system clock (XTAL1) as its time base. So strictly speaking, it is a Watchdog counter rather than a Watchdog timer. The WDT register will increment every 344,064 crystal clocks. The upper 8-bits of the time base register (WDTD) are used as the reload register of the WDT. The WDTS flag bit is set by WDT overflow and is not changed by WDT reset. User software can clear WDTS by writing ‘1' to it.
Two SFRs (WDTC and WDTD)control Watchdog timer operation. During idle mode, WDT operation is temporarily suspended, and resumes upon an interrupt exit from idle. The time-out period of the WDT is calculated as follows:
Period = (255 - WDTD) 344064 1/fCLK (XTAL1)
where WDTD is the value loaded into the WDTD register and fosc is the oscillator frequency
WDTC - Watchdog control register (address COH) bit allocation Bit addressable; Reset value: 00H Table: Bit 7 6 5 4 3 2 1 0 Symbol - - - WDOUT WDRE WDTS WDT SWDT
Table: WDTC - Watchdog control register (address COH) bit description Symbol > Description
WDOUT > Watchdog output enable. When this bit and WDRE are both set, a Watchdog reset will drive the reset pin active for 32 clocks. WDRE > Watchdog timer reset enable. When set enables a Watchdog timerreset.
WDTS > Watchdog timer reset flag, when set indicates that a WDT reset occurred. Reset in software. WDT > Watchdog timer refresh. Set by software to force a WDT reset.
SWDT > Start Watchdog timer, when set starts the WDT. When cleared,stops the WDT
Advance Thanks!
Actually if someone push Reset button for long time causes motors continuous run. and also problem related to devic that is programmed for logic high. I use logic 1 to start the motor bcoz predesigned driver(Circuit with relay) for AC Motor.
when i used in AT89S52 with Watchdog reset, it didn't start the motor after reset.
At that time DAN HENRY helped me. Where are u DAN?
I only want to use Watchdog by Interrupt as general Reset nothing else.
Bit 7 6 5 4 3 2 1 0 Symbol - - - WDOUT WDRE WDTS WDT SWDT Table: WDTC - Watchdog control register (address COH) bit description Symbol Description WDOUT >> Watchdog output enable. When this bit and WDRE are both set, a Watchdog reset will drive the reset pin active for 32 clocks. WDRE >> Watchdog timer reset enable. When set enables a Watchdog timerreset. WDTS >> Watchdog timer reset flag, when set indicates that a WDT reset occurred. Reset in software. WDT >> Watchdog timer refresh. Set by software to force a WDT reset. SWDT >> Start Watchdog timer, when set starts the WDT. When cleared,stops the WDT
I use logic 1 to start the motor bcoz predesigned driver(Circuit with relay) for AC Motor.
A driver circuit that turns on a peripheral during processor reset is wrong. It's a simple as that.
Port pins have documented states at reset for a reason --- it's so you can design the surrounding circuits so they do the right thing during reset.
So you've said several times now. You also claimed it "didn't work" --- which doesn't tell anybody anything. What you still have not said, in all these days, is what your actual problem is.
I used SWDT which Starts Watchdog timer, when set starts the WDT
which causes reset
I have written same on the TOP of thread!
But what is wrong? it doesn't reset uC.
SWDT which Starts Watchdog timer, when set starts the WDT which causes reset
I had a bit of time and, against every reason, took a glance at the datasheet.
"against every reason" because it is YOUR responsibility to read the datasheet.
However, the below seems to be your problem.
"To protect the system against software deadlock, the user software must refresh the WDT within a user-defined time period. If the software fails to do this periodical refresh, an internal hardware reset will be initiated if enabled (WDRE = 1). The software can be designed such that the WDT times out if the program does not work properly."
The code in the first post contains:
WDRE=1; SWDT=1;
SWDT which Starts Watchdog timer, when set starts the WDT
You've already demonstrated you can copy-paste from data sheets. But do you understand them.
Indeed you did. But nobody asked you questions about what you did. We asked questions about why you did it, and how exactly it failed to work.
But what is wrong?
Guess what, I've asked you that same question 4 days ago. You chose to consider that "rude".
it doesn't reset uC.
So we finally get an answer: you think there's no reset being done at all. How do you know that? A reset internal to the uC can be quite hard to detect from the outside.
Did you check that the interrupt handler is called in the first place?
ok! It takes aprrox 9 to 10 sec to Reset for 12Mhz clock
Thanks for helping Thank you so much
its:
WDTD=254;
.
Reading the original post would probably be a good idea.
glue logic is when you take some normal logic gates or similar and connects between your processor and the external equipment.
In this case, you should consider inverting the signal, to make sure that you get the expected behaviour when the processor is in the reset state.
If you want to improve on the concept, you could even add logic for an external watchdog, requiring the processor to regularly toggle one or more pins to prove that it is alive. This would improve the chance that a software error or a hardware lockup will not result in an unsupervised motor running 24x7 possibly burning out the motor, starting a fire or similar.
Thanks for your reply Per Westermark!
i used : Period = (255 - 0xF0) * 344064 * (1/12000000)
but it resets in 4 to 5 seconds
can you provide me suggestion for less than 1 second reset?