<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis MicrocontrollersのトピックRe: Reset Registers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464961#M63173</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;how can i Reset all of the registers of the CPU after bootloader is jumping to the Application software, in the Application Software. "&lt;BR /&gt;&lt;BR /&gt;As I understand what you wrote above:&lt;BR /&gt;&lt;BR /&gt;The bootloader has messed with lots of things, we don't know what, so we want to start as if we are starting from a clean reset out of the bootloader when it has jumped to our application.&lt;BR /&gt;&lt;BR /&gt;This is how that is handled:&lt;BR /&gt;&lt;BR /&gt;We look at the BOOTLOADER bit in RCM.&lt;BR /&gt;When we see that the bootloader was what got us to main(), we issue a software reset to reset the hardware registers to the data sheet values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How at this second boot we look at RCM again to see if we got here via either Watchdog or SWS reset.&lt;BR /&gt;SWS tells us that we got here because the bootloader started us and this is our reset from that event, and this is the second reset in this boot process.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If nothing special needs done on this second boot then no need to look at SWS and the software can treat it as it would POR or PIN-Reset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is what I have in my own vectors.c that is the first code executed out of hardware reset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* This overrides the weakly linked funciton in vectors.c so we can found out why we rebooted */&lt;BR /&gt;void bootloader_mr_setup( void );&lt;BR /&gt;void bootloader_mr_setup( void )&lt;BR /&gt;{&lt;BR /&gt;/*&lt;BR /&gt;* RCM_MR Indicates the boot source, the boot source remains set&lt;BR /&gt;* until the next System Reset or software can write logic one to&lt;BR /&gt;* clear the corresponding mode bit. While either bit is set the&lt;BR /&gt;* NMI input is disabled and the vector table is relocated to the&lt;BR /&gt;* ROM base address at 0x1C00_0000. These bits should be cleared by&lt;BR /&gt;* writing logic one before executing any code from either Flash or&lt;BR /&gt;* SRAM.&lt;BR /&gt;*&lt;BR /&gt;* A reset is forced to clear out anything that the ROM&lt;BR /&gt;* bootloader did, so we are sure we have the data sheet reset&lt;BR /&gt;* values.&lt;BR /&gt;*&lt;BR /&gt;* This method works around the buggy KL43/27/17 bootloaders as&lt;BR /&gt;* described in: "Problem Analysis and solutions for booting from&lt;BR /&gt;* ROM BOOTLOADER in KL series".&lt;BR /&gt;*/&lt;BR /&gt;boot_src_u16_n = ( ( ( uint32_t ) RCM_FM &amp;lt;&amp;lt; 8U ) | ( ( uint32_t ) RCM_MR ) );&lt;/P&gt;&lt;P&gt;if( 0U != ( RCM_MR &amp;amp; RCM_MR_BOOTROM_MASK ) )&lt;BR /&gt;{&lt;BR /&gt;RCM_MR = RCM_MR_BOOTROM_MASK; /* Clear the bits that indicated a bootlaoder boot via ROM */&lt;BR /&gt;RCM_FM = 0U; /* Boot from Flash not ROM on next reset */&lt;/P&gt;&lt;P&gt;SCB_AIRCR = ( SCB_AIRCR_VECTKEY( 0x05FAU ) | SCB_AIRCR_SYSRESETREQ_MASK ); /* Force a Software Reset */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;RCM_FM = 0U;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 26 May 2022 18:22:21 GMT</pubDate>
    <dc:creator>bobpaddock</dc:creator>
    <dc:date>2022-05-26T18:22:21Z</dc:date>
    <item>
      <title>Reset Registers</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1463134#M63156</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i implement firmware upgrade with bootloader.&lt;/P&gt;&lt;P&gt;i have a bootloader that use Uart, DMA, timers and interrupt.&lt;/P&gt;&lt;P&gt;how can i Reset all of the registers of the CPU after bootloader is jumping to the Application software, in the Application Software.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 09:49:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1463134#M63156</guid>
      <dc:creator>AsafTv</dc:creator>
      <dc:date>2022-05-24T09:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reset Registers</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464326#M63165</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/188636"&gt;@AsafTv&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope that you are doing excellent.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I understand , you want to have everything "clear" for the application usage.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure if you are using one of our Bootloaders and/or which Kinetis part.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I recommend you to take a look at the below function :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;/*!
 * @brief Prepare system for exiting the bootloader.
 *
 * Performs any cleanup necessary to restore the system to default state prior to
 * exiting the bootloader. This involves restoring the vector table to default,
 * managing the flash cache, and so on.
 *
 * This routine *must* be invoked prior to permanently exiting the bootloader.
 *
 * @param shutdown Specifies different uses for this function
 *       'kShutdownType_Shutdown' means clean up prior to permanently exiting the bootloader.
 *       'kShutdownType_Cleanup' means only clear (flush) the flash cache
 *       'kShutdownType_Reset' means only shutdown all peripherals.
 */
void shutdown_cleanup(shutdown_type_t shutdown);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This to get an idea of how the bootloader shutdown peripherals when jumping to the main application.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That function can be found in the Freedom Bootloader (flash resident bootloader). Specifically I checked this from the FRDM-K64F MCUXpresso SDK&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this could help you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Diego.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 22:43:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464326#M63165</guid>
      <dc:creator>diego_charles</dc:creator>
      <dc:date>2022-05-25T22:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reset Registers</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464757#M63167</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;my boot software is old and i build new application.&lt;/P&gt;&lt;P&gt;the bootloader is use hardware peripheral and interrupt with his vector interrupt.&lt;/P&gt;&lt;P&gt;the application has vector inetrrupt.&lt;/P&gt;&lt;P&gt;the bootloader is not clear hardware register and interrupt&amp;nbsp;&lt;/P&gt;&lt;P&gt;i see that the hardware register (UART, UDMA, DMUX) is not clear after jump to Application.&lt;/P&gt;&lt;P&gt;there is a way&amp;nbsp; to clear/Reset hardware Register in the application&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 11:52:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464757#M63167</guid>
      <dc:creator>AsafTv</dc:creator>
      <dc:date>2022-05-26T11:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reset Registers</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464862#M63169</link>
      <description>&lt;P&gt;Generating a software reset will clear all of the registers to the data sheet values.&lt;BR /&gt;&lt;BR /&gt;You'll need to look at the RCM registers of your part (you did not say what it was) to decide when to do this.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here is example code to do the software reset.&lt;BR /&gt;When the code restarts SWS will be set in RCM.&lt;/P&gt;&lt;P&gt;Someplace in main() to decide how to handle start up:&lt;BR /&gt;&lt;BR /&gt;/*&lt;BR /&gt;* RCM_(S)SRS0:&lt;BR /&gt;*&lt;BR /&gt;* 7 6 5 4 3 2 1 0&lt;BR /&gt;* POR PIN WDOG 0 0 0 LVD WAKEUP&lt;BR /&gt;*&lt;BR /&gt;* POR (including LVD) — 0x82&lt;BR /&gt;• LVD (without POR) — 0x02&lt;BR /&gt;• VLLS mode wakeup due to RESET pin assertion — 0x41&lt;BR /&gt;• VLLS mode wakeup due to other wakeup sources — 0x01&lt;BR /&gt;* RESET pin assertion — 0x40&lt;BR /&gt;• Other reset — a bit is set if its corresponding reset source&lt;BR /&gt;* caused the reset&lt;BR /&gt;*&lt;BR /&gt;* RCM_(S)SRS1:&lt;BR /&gt;* 7 6 5 4 3 2 1 0&lt;BR /&gt;* 0 0 SACKERR 0 MDM_AP SW LOCKUP 0&lt;BR /&gt;* ACKERR: Stop Mode Acknowledge Error Reset&lt;BR /&gt;* MDM_AP (Debugger): MDM-AP System Reset Request&lt;BR /&gt;*&lt;BR /&gt;* SW (Software): Indicates a reset has been caused by software&lt;BR /&gt;* setting of SYSRESETREQ bit in Application&lt;BR /&gt;* Interrupt and Reset Control Register in the&lt;BR /&gt;* ARM core.&lt;BR /&gt;*&lt;BR /&gt;* LOCKUP (Core Lockup): Indicates a reset has been caused by the&lt;BR /&gt;* ARM core indication of a LOCKUP event&lt;BR /&gt;*/&lt;BR /&gt;wdt_src_u16 = (((uint16_t) RCM_SSRS1 &amp;lt;&amp;lt; 8U) | ((uint16_t) RCM_SSRS0) );&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Function to call to clear to data sheet values:&lt;BR /&gt;&lt;BR /&gt;#define ATTR_NO_INSTRUMENT_FUNCTION __attribute__( ( no_instrument_function ) )&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/*&lt;BR /&gt;* The CPSID instruction is self-synchronized to the instruction&lt;BR /&gt;* stream and there is no requirement to insert memory barrier&lt;BR /&gt;* instructions after CPSID.&lt;BR /&gt;*/&lt;BR /&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void irq_disable( void )&lt;BR /&gt;{&lt;BR /&gt;__asm__ __volatile__ ("cpsid i");&lt;BR /&gt;__asm__ __volatile__ ("" ::: "memory");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;static inline ATTR_NO_INSTRUMENT_FUNCTION void sync_barrier_data( void )&lt;BR /&gt;{&lt;BR /&gt;__asm__ __volatile__ ("dsb");&lt;BR /&gt;__asm__ __volatile__ ("" ::: "memory");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;void __attribute__ ((noreturn)) reset_mcu( void );&lt;/P&gt;&lt;P&gt;void __attribute__ ((noreturn)) reset_mcu( void )&lt;BR /&gt;{&lt;BR /&gt;/*&lt;BR /&gt;* A DSB is required before generating self-reset to ensure all&lt;BR /&gt;* outstanding transfers are completed. The use of the CPSID I&lt;BR /&gt;* instruction is optional.&lt;BR /&gt;* sync_barrier_data();&lt;BR /&gt;*/&lt;BR /&gt;irq_disable();&lt;BR /&gt;sync_barrier_data();&lt;/P&gt;&lt;P&gt;SCB_AIRCR = (SCB_AIRCR_VECTKEY(0x05FAU) | SCB_AIRCR_SYSRESETREQ_MASK);&lt;/P&gt;&lt;P&gt;for(;;)&lt;BR /&gt;{&lt;BR /&gt;;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 14:19:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464862#M63169</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2022-05-26T14:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Reset Registers</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464929#M63171</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;you mast to read my messages.&lt;/P&gt;&lt;P&gt;i don't want to reset the cpu just clear all of the registers in the Application (not in the bootloader) like in Power up after the bootloader is jump to application.&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 16:20:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464929#M63171</guid>
      <dc:creator>AsafTv</dc:creator>
      <dc:date>2022-05-26T16:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reset Registers</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464961#M63173</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;how can i Reset all of the registers of the CPU after bootloader is jumping to the Application software, in the Application Software. "&lt;BR /&gt;&lt;BR /&gt;As I understand what you wrote above:&lt;BR /&gt;&lt;BR /&gt;The bootloader has messed with lots of things, we don't know what, so we want to start as if we are starting from a clean reset out of the bootloader when it has jumped to our application.&lt;BR /&gt;&lt;BR /&gt;This is how that is handled:&lt;BR /&gt;&lt;BR /&gt;We look at the BOOTLOADER bit in RCM.&lt;BR /&gt;When we see that the bootloader was what got us to main(), we issue a software reset to reset the hardware registers to the data sheet values.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How at this second boot we look at RCM again to see if we got here via either Watchdog or SWS reset.&lt;BR /&gt;SWS tells us that we got here because the bootloader started us and this is our reset from that event, and this is the second reset in this boot process.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If nothing special needs done on this second boot then no need to look at SWS and the software can treat it as it would POR or PIN-Reset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is what I have in my own vectors.c that is the first code executed out of hardware reset:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* This overrides the weakly linked funciton in vectors.c so we can found out why we rebooted */&lt;BR /&gt;void bootloader_mr_setup( void );&lt;BR /&gt;void bootloader_mr_setup( void )&lt;BR /&gt;{&lt;BR /&gt;/*&lt;BR /&gt;* RCM_MR Indicates the boot source, the boot source remains set&lt;BR /&gt;* until the next System Reset or software can write logic one to&lt;BR /&gt;* clear the corresponding mode bit. While either bit is set the&lt;BR /&gt;* NMI input is disabled and the vector table is relocated to the&lt;BR /&gt;* ROM base address at 0x1C00_0000. These bits should be cleared by&lt;BR /&gt;* writing logic one before executing any code from either Flash or&lt;BR /&gt;* SRAM.&lt;BR /&gt;*&lt;BR /&gt;* A reset is forced to clear out anything that the ROM&lt;BR /&gt;* bootloader did, so we are sure we have the data sheet reset&lt;BR /&gt;* values.&lt;BR /&gt;*&lt;BR /&gt;* This method works around the buggy KL43/27/17 bootloaders as&lt;BR /&gt;* described in: "Problem Analysis and solutions for booting from&lt;BR /&gt;* ROM BOOTLOADER in KL series".&lt;BR /&gt;*/&lt;BR /&gt;boot_src_u16_n = ( ( ( uint32_t ) RCM_FM &amp;lt;&amp;lt; 8U ) | ( ( uint32_t ) RCM_MR ) );&lt;/P&gt;&lt;P&gt;if( 0U != ( RCM_MR &amp;amp; RCM_MR_BOOTROM_MASK ) )&lt;BR /&gt;{&lt;BR /&gt;RCM_MR = RCM_MR_BOOTROM_MASK; /* Clear the bits that indicated a bootlaoder boot via ROM */&lt;BR /&gt;RCM_FM = 0U; /* Boot from Flash not ROM on next reset */&lt;/P&gt;&lt;P&gt;SCB_AIRCR = ( SCB_AIRCR_VECTKEY( 0x05FAU ) | SCB_AIRCR_SYSRESETREQ_MASK ); /* Force a Software Reset */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;RCM_FM = 0U;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 18:22:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Reset-Registers/m-p/1464961#M63173</guid>
      <dc:creator>bobpaddock</dc:creator>
      <dc:date>2022-05-26T18:22:21Z</dc:date>
    </item>
  </channel>
</rss>

