Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 9 of 9

Thread: T4 software restart procedure and freeram function

  1. #1
    Senior Member
    Join Date
    Aug 2017
    Posts
    129

    T4 software restart procedure and freeram function

    On the T4 is there a procedure for performing a software restart? Could it be as simple as calling ResetHandler() in startup.c?
    It seems to me that there was talk of how to get the memory usage for T4 ram in the T4 First Beta Test thread but I can't seem to find it.
    Can anybody point me to this information?

    Thanks

  2. #2
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    This might help: https://forum.pjrc.com/threads/54711...l=1#post207343

    UPDATE:
    THink this is all you need to do:
    Code:
    SCB_AIRCR = 0x05FA0004;
    And for reference:
    https://mcuoneclipse.com/2015/07/01/...with-software/

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,585
    Yup, just write to AIRCR. That's a register from the ARM core, so it's usually not documented in the chip's reference manual.

  4. #4
    Senior Member
    Join Date
    Aug 2017
    Posts
    129
    @jms513 and @Paul - Thanks guys.
    Instant answers. This forum is the best

  5. #5
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    @Paul - @wwatson

    Warning - the command I listed shuts down the 1062. To restart the sketch I had to remove power and reapply power. It seems to behave the same way as the power off button. Just tried it with the blink sketch.

    UPDATE:
    I just put it on the PRJC breakout board and issued the reset command - the chip shut down but the green power light stayed on. Pressing the on off button brought it back to life.
    Last edited by mjs513; 09-09-2019 at 12:22 AM.

  6. #6
    Senior Member
    Join Date
    Aug 2017
    Posts
    129
    Quote Originally Posted by mjs513 View Post
    @Paul - @wwatson

    Warning - the command I listed shuts down the 1062. To restart the sketch I had to remove power and reapply power. It seems to behave the same way as the power off button. Just tried it with the blink sketch.

    UPDATE:
    I just put it on the PRJC breakout board and issued the reset command - the chip shut down but the green power light stayed on. Pressing the on off button brought it back to life.
    @mjs513 - I just set it up to use ctrl-alt-del (USB keyboard) and it just locks up so I will dig deeper and see what I come up with. Going back to work tomorrow after a weeks vacation playing with the T4.

    Thanks for the info

  7. #7
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,752
    Quote Originally Posted by wwatson View Post
    @mjs513 - I just set it up to use ctrl-alt-del (USB keyboard) and it just locks up so I will dig deeper and see what I come up with. Going back to work tomorrow after a weeks vacation playing with the T4.

    Thanks for the info
    I asked this on the T4_Beta thread but never tried it - @mjs513 followed up with this info post #3105:
    Quote Originally Posted by PaulStoffregen View Post
    Sure. Use AIRCR, just like on all other 32 bit ARM.
    @defragster, @Paul - I found this on AIRCR for ARM processors, https://mcuoneclipse.com/2015/07/01/...with-software/, will this do the trick?
    Code:
    void KIN1_SoftwareReset(void)
    {
      /* Generic way to request a reset from software for ARM Cortex */
      /* See https://community.freescale.com/thread/99740
         To write to this register, you must write 0x5FA to the VECTKEY field, otherwise the processor ignores the write.
         SYSRESETREQ will cause a system reset asynchronously, so need to wait afterwards.
       */
    #if KIN1_IS_USING_KINETIS_SDK
      SCB_AIRCR = (0x5FA<<SCB_AIRCR_VECTKEY_Pos)|SCB_AIRCR_SYSRESETREQ_Msk;
    #else
      SCB_AIRCR = SCB_AIRCR_VECTKEY(0x5FA) | SCB_AIRCR_SYSRESETREQ_MASK;
    #endif
      for(;;) {
        /* wait until reset */
      }
    }
    just not sure what needs to be changed leave that to you defragster.

  8. #8
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,113
    @wwatson - @defragster

    Yeah that function pretty boils down to that one single line to set the SCB_AICR.

    from the core cm7.h file:
    Code:
    #define SCB_AIRCR_VECTKEY_Pos              16U                                            /*!< SCB AIRCR: VECTKEY Position */
    #define SCB_AIRCR_VECTKEY_Msk              (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos)            /*!< SCB AIRCR: VECTKEY Mask */
    
    #define SCB_AIRCR_SYSRESETREQ_Pos           2U                                            /*!< SCB AIRCR: SYSRESETREQ Position */
    #define SCB_AIRCR_SYSRESETREQ_Msk          (1UL << SCB_AIRCR_SYSRESETREQ_Pos)             /*!< SCB AIRCR: SYSRESETREQ Mask */
    when you do the math comes out the same way.
    Last edited by mjs513; 09-09-2019 at 11:41 AM.

  9. #9
    Senior Member
    Join Date
    Aug 2017
    Posts
    129
    Quote Originally Posted by mjs513 View Post
    @Paul - @wwatson

    Warning - the command I listed shuts down the 1062. To restart the sketch I had to remove power and reapply power. It seems to behave the same way as the power off button. Just tried it with the blink sketch.

    UPDATE:
    I just put it on the PRJC breakout board and issued the reset command - the chip shut down but the green power light stayed on. Pressing the on off button brought it back to life.
    @mjs513 - Sorry for the late response. I had the same result. Played with the the information you provided and came up with nothing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •