This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

IWDG and NVIC_SystemReset on Keil MCBSTM32

Hi all, I'm crossposting this from ST forum since i didn't get any response and the question is still open and becoming urgent in choosing the microcontrollore for our project.

I'm using the keil MCBSTM32 demoboard (F103RB micro) and I'm coding with the latest std_periph lib (V3.1.0 - 06/19/2009) with keil uVision 3 V3.85 and ULINK-Me.
The board is powered from both the usb cable and the ULINK (ULINK is not supposed to power the board, but I've seen that even if the main usb power cabe is diabled the board is powered with just the ULINK connected).

The indipendent watchdog doesn't seems to work properly if the debugger is running. All seems ok if the debugger and ulink are off. Why ???
From the board schematics, the NRST pin is connected to both the board reset button AND the jtag connector.

Also, in this unclear situation, the undocumented function NVIC_SystemReset (taken from some FLASH protection example) does not works (it seems to block on the while(1) infinite cycle waiting for reset after setting the NVIC_SYSRESETREQ bit.
Does this function relay on the IWDG to reset ?
Anyone with similar problem ?

  • Systemreset:
    Setting bit SYSRESETREQ to request an systemreset will only work at privileged mode. If you try to set this bit at unprivileged mode a hardfault ecxeption occurs.

    Watchdog:
    It is possible that the watchdog timer keeps running during debug stop. Please have a look to the STM32DBG.ini file and check the behaviour during debug stop.

  • Hi Raphael,

    thnx for the reply but... I'm not sure I did undertsand correctly:

    1) Systemreset
    I do NOT change any privilege at startup, so the micro should start in thread/privileged mode, shouldn't it ?
    As a result, setting the SYSRESETREQ should cause a reset. Anyway, the debugger shows that the execution halts in the while(1); loop after bit set, and never enters the default HardFault_Handler.
    ??

    2) Watchdog
    I checked the STM32DBG.ini file and confirm that IWDG does NOT stop when core is haltded (i didn't stop anyway, debugger was just running).
    I also tried to switch to SW insted of JTAG and assigned an alternate GPIO function to jtag reset signal, but the behavior is the same.

    Any other hint ??

  • Hi Marco

    Systemreset:
    I use the following code to request a systemrest out of unprivileged mode.

    void __svc(1) PeriResetSystemSVC( void );
    void __SVC_1                    ( void ) {
    
        // note: beginning of protected function to reset the system
        __disable_irq();
    
        // set software reset flag
        NVIC_GenerateSystemReset();
        // hack: for debug endless loop should never be reached
        while( 1 ) {
            __nop();
        }
    }
    
    

    The differences are that the irq get disbaled and that I use an older version of the ST fimrware lib. But it isn't obviously to me, way your code isn't running.

    Watchdog:
    Perhaps you have to disable the "run to main()" check box at the debug settings?

  • Dear sir:
    Like the topic.
    Where i can get it.
    Thank you very much.

  • Hi Raphael,

    1 SystemReset
    My code is much like your:

    if (ProtectedPages != 0x00000000) {
    
      //bootloader pages are not protected, protect them
      FLASHStatus = FLASH_EnableWriteProtection(D_FLASH_BOOTLOADER_PROTECTED_PAGES);
    
      Led_1_Turn_On(0,0);  //TODO TEST, remove when done
    
      // Generate System Reset to load the new option byte values
      __disable_irq();
      NVIC_SystemReset();
    
    } else {
    
      Led_1_Turn_Off();  //TODO TEST, remove when done
    
    }
    

    But it doesn't work...

    2) Watchdog
    I disabled the "run to main()" checkbox but nothing changed.

    Can I ask you which board are you using (if you're using one...)

  • No; the topic of this thread is IWDG and NVIC_SystemReset on Keil MCBSTM32

    Do not hijack existing threads with unrelated requests!

    Also note that it has nothing to do with Keil tools or products - so this isn't even the correct forum in which to ask.

    Have you tried google?

  • Hi Marco

    We use our own board. We use the SWD configuration and uLink2 for debugging and programming. The NRST pin is also connected to the SWD connector but the pin B4/TRST isn't connected as ST did at their eval board STM3210B.