This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi!
I'm using Piccolo and I'm trying to use the NMI watchdog to let the system in a defined state before reset.
I get the NMIINT, but I don't clear the flags, as I wanna let the system reset.
// NmiIntruptRegs.NMIFLGCLR.bit.CLOCKFAIL = 1;
// NmiIntruptRegs.NMIFLGCLR.bit.NMIINT = 1;
I check the MCLKSTS bit in PLLSTS after reset, but is not set.
The CLOCKFAIL bit in NMIFLG is set.
Maybe I don't test it right. I simulate a clock fail by writing:
NmiIntruptRegs.NMIFLGFRC.bit.CLOCKFAIL = 1;
As I understood, if the NMIRESETSEL =1, the CLOCKFAIL signal will be generate in case of a clock failure. This will trigger the NMIINT and start the NMIWD counter. If I don't clear the flags, the counter expired, generates NMI reset, which is passed to MCLKRS, and the system will reset. But if a MCLKRS is generated, shouldn't MCLKSTS be set?
Is there another possibility to test this?
Thank you,
Monica
Hi Monica
try OSCOFF bits in PLLSTS or CLKCTL registers. for ex: configure device to run on INTOSC2 or external clock with missing cloc kenabled and then turn off the input to the PLL. This should set the MCLKSTS bit.
Best Regards
Santosh
Hi Santosh!
I've tried to do this, but I've also disabled INTOSC1. I've done something wrong for sure, coz nothing works anymore, moreover I cannot connect anymore to the board to flash it again. I assume I don't have any clock signal anymore. Is there a possibility to flash it again in this case? Otherwise... I'm just... dead
Thanks,
Monica
Hi Monica,
can you put the device in WaitBoot Mode and connect to JTAG, Erase flash and update your program? Please switch the CPU to work with INTOSC2 and turnOFF INTOSC2 or switch CPU to work with XCLKIN and then remove XCLK to simulate a missing clock.
Please let us know how it goes.
Best Regards
santosh
Hi!
I don't know how to go in WaitBoot mode. I don't have JTAG, only USB, I have the experimenter kit with control card.
I'm trying to connect from CCS, but it's not working.Can I go in WaitBoot without having the connection with the board? It's something in the hardware I have to do?
thanks,
Monica
Please refer to the device boot ROM guide for details on waitBoot Mode.
Please refer to control card schematics or board manual on how to set up the boot modes.
Best Regards
Santosh
Hi again!
thanks, I've managed to program again the board, but still I don't see MCLKSTS being set. I get the reset, I check MCLKSTS after reset, but it's not set. Another thing that I don't get is why I get a reset immediately, if I have the NMIINT enabled? The clockfail should not trigger NMIINT? What am I missing here?
I simulate the error by writing:
EALLOW;
//switch to INTOSC2
SysCtrlRegs.CLKCTL.all = 0x6000; // Set XTALOSCOFF=1 & XCLKINOFF=1
SysCtrlRegs.CLKCTL.all = 0x6003; // Set OSCCLKLSRCSEL=1 & OSCCLKSRC2SEL=1
// turn off INTOSC2
SysCtrlRegs.CLKCTL.bit.INTOSC2OFF=1;
EDIS;
I check MCLKSTS:
void main(void)
{
/
if (SysCtrlRegs.PLLSTS.bit.MCLKSTS != 0)
{
flag_CLOCK=1;
}
else {flag_CLOCK=0;}
......
And I have set:
SysCtrlRegs.CLKCTL.bit.NMIRESETSEL = 1;
NmiIntruptRegs.NMICFG.bit.CLOCKFAIL = 1;
I check also:
if (NmiIntruptRegs.NMIFLG.bit.CLOCKFAIL != 0)
{
flag_FAIL=1;
}
else {flag_FAIL=0;}
... and the flag_FAIL=1 after reset.
If CLOCKFAIL is set, why I don't get the NMIINT? Even stranger is that NMIFLG register = 0x0003; so there was a NMIINT, right?
But, the reset was caused by the watchdog, according to the flags I have in my code.
Regards,
monica
Hi Monica
which one are you doing first?
NMIRESETSEL = 1 or OSC2OFF? and is your watchDog disabled while doing this test?
Best Regards
Santosh
Hi Monica,
should have clarified earlier... MCLKSTS is only set if INTOSC1 goes missing, while INTOSC1 is the main clock source. MCLKSTS indicates that CPU started in LIMP mode.
when INTOSC2 or XCLK is the configured as the main clock source and if they go missing, then device will switch to INTOSC1 asnd MCLKSTS is cleared automatically in hardware and if NMIRESETSEL is '1' then NMI is generated else a reset is generated.
in order to test code that is written for MCLKSTS, you should use PLLSTS->OSCOFF bit. By setting this bit the actual oscillators are not OFF, but it simulates a missing clock condition and sets MCLKSTS.
is this what you are looking for?
Best Regards
Santosh
Hi Santosh!
First I do all the settings. Then I switch the clock to INTOSC2, then OSC2OFF.
The watchdog is enabled.
Regards,
monica
Thanks!
I'll try that.
What I'm looking for is a way to simulate a missing clock so that I can check that in case this happens, I get an NMI INT so that I let the system in a defined state, set the flags to know what happened and then let the device do the reset. The question is why I don't get the NMIINT when I stop INTOSC2? I understood a CLOCKFAIL is generated in any case of missing clock, right? XCLK, INTOSC2 or INTOSC1.
I'll come back with an update after several tests.
Regards,
monica
Thanks Santosh
I've managed to simulate the missing clock using OSCOFF. I've noticed it have to put it back to 0 after reset, otherwise it remains on 1, right?
After reset, I can see both CLOCKFAIL and MCLKSTS are set. The NMIINT is triggered.
Still I don't understand why I get a watchdog reset if I simulate a missing clock when INTOSC2 is set as main clock.
Regards,
Monica
Hi Monica,
yes, OSCOFF has to be cleared before clearing MCLKSTS. Clearing OSCOFF here is equivalent to clearing the actual cause for Missing Clock in a real scenario.
regarding below, are you sure about this? CLKCTL.WDCLKSRCSEL bit is reset whenever there is a missing clock detected.
Are you servicing watchdog in your NMI handler? and be sure to service your watchDog just before you turnoff INTOSC2, to avoid any race conditions between missing clock NMI and WDRST while debugging.
Monica Zolog said:Still I don't understand why I get a watchdog reset if I simulate a missing clock when INTOSC2 is set as main clock.
Best Regards
Santosh
Hi Monica,
also please check the errata on WatchDog and 'CPU switching to INTOSC2', on Piccolo class device, so that you are aware of those while debugging.
Best Regards
Santosh