<?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>topic Cortex M4F PendSV with FPU in S32K</title>
    <link>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2136881#M51111</link>
    <description>&lt;P&gt;xPortPendSVHandler:&lt;/P&gt;&lt;P&gt;ldr r3, =pxCurrentTCB&lt;BR /&gt;ldr r2, [r3] /* r2 = pxCurrentTCB. */&lt;BR /&gt;ldr r1, [r2] /* r1 = Location where the context should be saved. */&lt;/P&gt;&lt;P&gt;/*------------ Save Context. ----------- */&lt;BR /&gt;mrs r3, control&lt;BR /&gt;mrs r0, psp&lt;BR /&gt;isb&lt;/P&gt;&lt;P&gt;add r0, r0, #0x20 /* Move r0 to location where s0 is saved. */&lt;BR /&gt;tst lr, #0x10&lt;BR /&gt;ittt eq&lt;BR /&gt;vstmiaeq r1!, {s16-s31} /* Store s16-s31. */&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;vldmiaeq r0, {s0-s16} /* Copy hardware saved FP context into s0-s16. */&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;vstmiaeq r1!, {s0-s16} /* Store hardware saved FP context. */&lt;BR /&gt;sub r0, r0, #0x20 /* Set r0 back to the location of hardware saved context. */&lt;/P&gt;&lt;P&gt;stmia r1!, {r3-r11, lr} /* Store CONTROL register, r4-r11 and LR. */&lt;BR /&gt;ldmia r0, {r4-r11} /* Copy hardware saved context into r4-r11. */&lt;BR /&gt;stmia r1!, {r0, r4-r11} /* Store original PSP (after hardware has saved context) and the hardware saved context. */&lt;BR /&gt;str r1, [r2] /* Save the location from where the context should be restored as the first member of TCB. */&lt;/P&gt;&lt;P&gt;/*---------- Select next task. --------- */&lt;BR /&gt;mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY&lt;BR /&gt;#if ( configENABLE_ERRATA_837070_WORKAROUND == 1 )&lt;BR /&gt;cpsid i /* ARM Cortex-M7 r0p1 Errata 837070 workaround. */&lt;BR /&gt;#endif&lt;BR /&gt;msr basepri, r0&lt;BR /&gt;dsb&lt;BR /&gt;isb&lt;BR /&gt;#if ( configENABLE_ERRATA_837070_WORKAROUND == 1 )&lt;BR /&gt;cpsie i /* ARM Cortex-M7 r0p1 Errata 837070 workaround. */&lt;BR /&gt;#endif&lt;BR /&gt;bl vTaskSwitchContext&lt;BR /&gt;mov r0, #0&lt;BR /&gt;msr basepri, r0&lt;/P&gt;&lt;P&gt;/*------------ Program MPU. ------------ */&lt;BR /&gt;ldr r3, =pxCurrentTCB&lt;BR /&gt;ldr r2, [r3] /* r2 = pxCurrentTCB. */&lt;BR /&gt;add r2, r2, #4 /* r2 = Second item in the TCB which is xMPUSettings. */&lt;/P&gt;&lt;P&gt;dmb /* Complete outstanding transfers before disabling MPU. */&lt;BR /&gt;ldr r0, =0xe000ed94 /* MPU_CTRL register. */&lt;BR /&gt;ldr r3, [r0] /* Read the value of MPU_CTRL. */&lt;BR /&gt;bic r3, #1 /* r3 = r3 &amp;amp; ~1 i.e. Clear the bit 0 in r3. */&lt;BR /&gt;str r3, [r0] /* Disable MPU. */&lt;/P&gt;&lt;P&gt;ldr r0, =0xe000ed9c /* Region Base Address register. */&lt;BR /&gt;ldmia r2!, {r4-r11} /* Read 4 sets of MPU registers [MPU Region # 0 - 3]. */&lt;BR /&gt;stmia r0, {r4-r11} /* Write 4 sets of MPU registers [MPU Region # 0 - 3]. */&lt;/P&gt;&lt;P&gt;#ifdef configTOTAL_MPU_REGIONS&lt;BR /&gt;#if ( configTOTAL_MPU_REGIONS == 16 )&lt;BR /&gt;ldmia r2!, {r4-r11} /* Read 4 sets of MPU registers [MPU Region # 4 - 7]. */&lt;BR /&gt;stmia r0, {r4-r11} /* Write 4 sets of MPU registers. [MPU Region # 4 - 7]. */&lt;BR /&gt;ldmia r2!, {r4-r11} /* Read 4 sets of MPU registers [MPU Region # 8 - 11]. */&lt;BR /&gt;stmia r0, {r4-r11} /* Write 4 sets of MPU registers. [MPU Region # 8 - 11]. */&lt;BR /&gt;#endif /* configTOTAL_MPU_REGIONS == 16. */&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;ldr r0, =0xe000ed94 /* MPU_CTRL register. */&lt;BR /&gt;ldr r3, [r0] /* Read the value of MPU_CTRL. */&lt;BR /&gt;orr r3, #1 /* r3 = r3 | 1 i.e. Set the bit 0 in r3. */&lt;BR /&gt;str r3, [r0] /* Enable MPU. */&lt;BR /&gt;dsb /* Force memory writes before continuing. */&lt;/P&gt;&lt;P&gt;/*---------- Restore Context. ---------- */&lt;BR /&gt;ldr r3, =pxCurrentTCB&lt;BR /&gt;ldr r2, [r3] /* r2 = pxCurrentTCB. */&lt;BR /&gt;ldr r1, [r2] /* r1 = Location of saved context in TCB. */&lt;/P&gt;&lt;P&gt;ldmdb r1!, {r0, r4-r11} /* r0 contains PSP after the hardware had saved context. r4-r11 contain hardware saved context. */&lt;BR /&gt;msr psp, r0&lt;BR /&gt;stmia r0!, {r4-r11} /* Copy the hardware saved context on the task stack. */&lt;BR /&gt;ldmdb r1!, {r3-r11, lr} /* r3 contains CONTROL register. r4-r11 and LR restored. */&lt;BR /&gt;msr control, r3&lt;/P&gt;&lt;P&gt;tst lr, #0x10&lt;BR /&gt;ittt eq&lt;BR /&gt;vldmdbeq r1!, {s0-s16} /* s0-s16 contain hardware saved FP context. */&lt;BR /&gt;vstmiaeq r0!, {s0-s16} /* Copy hardware saved FP context on the task stack. */&lt;BR /&gt;vldmdbeq r1!, {s16-s31} /* Restore s16-s31. */&lt;/P&gt;&lt;P&gt;str r1, [r2] /* Save the location where the context should be saved next as the first member of TCB. */&lt;BR /&gt;bx lr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I don't understand why it is S0~S&lt;FONT color="#FF0000"&gt;16&lt;/FONT&gt;?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;S0~S15 and status reg are pushed into stack by hardware, why copy it again?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope get your direction and advice！&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Jul 2025 12:34:26 GMT</pubDate>
    <dc:creator>LijieDu</dc:creator>
    <dc:date>2025-07-20T12:34:26Z</dc:date>
    <item>
      <title>Cortex M4F PendSV with FPU</title>
      <link>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2136881#M51111</link>
      <description>&lt;P&gt;xPortPendSVHandler:&lt;/P&gt;&lt;P&gt;ldr r3, =pxCurrentTCB&lt;BR /&gt;ldr r2, [r3] /* r2 = pxCurrentTCB. */&lt;BR /&gt;ldr r1, [r2] /* r1 = Location where the context should be saved. */&lt;/P&gt;&lt;P&gt;/*------------ Save Context. ----------- */&lt;BR /&gt;mrs r3, control&lt;BR /&gt;mrs r0, psp&lt;BR /&gt;isb&lt;/P&gt;&lt;P&gt;add r0, r0, #0x20 /* Move r0 to location where s0 is saved. */&lt;BR /&gt;tst lr, #0x10&lt;BR /&gt;ittt eq&lt;BR /&gt;vstmiaeq r1!, {s16-s31} /* Store s16-s31. */&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;vldmiaeq r0, {s0-s16} /* Copy hardware saved FP context into s0-s16. */&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;vstmiaeq r1!, {s0-s16} /* Store hardware saved FP context. */&lt;BR /&gt;sub r0, r0, #0x20 /* Set r0 back to the location of hardware saved context. */&lt;/P&gt;&lt;P&gt;stmia r1!, {r3-r11, lr} /* Store CONTROL register, r4-r11 and LR. */&lt;BR /&gt;ldmia r0, {r4-r11} /* Copy hardware saved context into r4-r11. */&lt;BR /&gt;stmia r1!, {r0, r4-r11} /* Store original PSP (after hardware has saved context) and the hardware saved context. */&lt;BR /&gt;str r1, [r2] /* Save the location from where the context should be restored as the first member of TCB. */&lt;/P&gt;&lt;P&gt;/*---------- Select next task. --------- */&lt;BR /&gt;mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY&lt;BR /&gt;#if ( configENABLE_ERRATA_837070_WORKAROUND == 1 )&lt;BR /&gt;cpsid i /* ARM Cortex-M7 r0p1 Errata 837070 workaround. */&lt;BR /&gt;#endif&lt;BR /&gt;msr basepri, r0&lt;BR /&gt;dsb&lt;BR /&gt;isb&lt;BR /&gt;#if ( configENABLE_ERRATA_837070_WORKAROUND == 1 )&lt;BR /&gt;cpsie i /* ARM Cortex-M7 r0p1 Errata 837070 workaround. */&lt;BR /&gt;#endif&lt;BR /&gt;bl vTaskSwitchContext&lt;BR /&gt;mov r0, #0&lt;BR /&gt;msr basepri, r0&lt;/P&gt;&lt;P&gt;/*------------ Program MPU. ------------ */&lt;BR /&gt;ldr r3, =pxCurrentTCB&lt;BR /&gt;ldr r2, [r3] /* r2 = pxCurrentTCB. */&lt;BR /&gt;add r2, r2, #4 /* r2 = Second item in the TCB which is xMPUSettings. */&lt;/P&gt;&lt;P&gt;dmb /* Complete outstanding transfers before disabling MPU. */&lt;BR /&gt;ldr r0, =0xe000ed94 /* MPU_CTRL register. */&lt;BR /&gt;ldr r3, [r0] /* Read the value of MPU_CTRL. */&lt;BR /&gt;bic r3, #1 /* r3 = r3 &amp;amp; ~1 i.e. Clear the bit 0 in r3. */&lt;BR /&gt;str r3, [r0] /* Disable MPU. */&lt;/P&gt;&lt;P&gt;ldr r0, =0xe000ed9c /* Region Base Address register. */&lt;BR /&gt;ldmia r2!, {r4-r11} /* Read 4 sets of MPU registers [MPU Region # 0 - 3]. */&lt;BR /&gt;stmia r0, {r4-r11} /* Write 4 sets of MPU registers [MPU Region # 0 - 3]. */&lt;/P&gt;&lt;P&gt;#ifdef configTOTAL_MPU_REGIONS&lt;BR /&gt;#if ( configTOTAL_MPU_REGIONS == 16 )&lt;BR /&gt;ldmia r2!, {r4-r11} /* Read 4 sets of MPU registers [MPU Region # 4 - 7]. */&lt;BR /&gt;stmia r0, {r4-r11} /* Write 4 sets of MPU registers. [MPU Region # 4 - 7]. */&lt;BR /&gt;ldmia r2!, {r4-r11} /* Read 4 sets of MPU registers [MPU Region # 8 - 11]. */&lt;BR /&gt;stmia r0, {r4-r11} /* Write 4 sets of MPU registers. [MPU Region # 8 - 11]. */&lt;BR /&gt;#endif /* configTOTAL_MPU_REGIONS == 16. */&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;ldr r0, =0xe000ed94 /* MPU_CTRL register. */&lt;BR /&gt;ldr r3, [r0] /* Read the value of MPU_CTRL. */&lt;BR /&gt;orr r3, #1 /* r3 = r3 | 1 i.e. Set the bit 0 in r3. */&lt;BR /&gt;str r3, [r0] /* Enable MPU. */&lt;BR /&gt;dsb /* Force memory writes before continuing. */&lt;/P&gt;&lt;P&gt;/*---------- Restore Context. ---------- */&lt;BR /&gt;ldr r3, =pxCurrentTCB&lt;BR /&gt;ldr r2, [r3] /* r2 = pxCurrentTCB. */&lt;BR /&gt;ldr r1, [r2] /* r1 = Location of saved context in TCB. */&lt;/P&gt;&lt;P&gt;ldmdb r1!, {r0, r4-r11} /* r0 contains PSP after the hardware had saved context. r4-r11 contain hardware saved context. */&lt;BR /&gt;msr psp, r0&lt;BR /&gt;stmia r0!, {r4-r11} /* Copy the hardware saved context on the task stack. */&lt;BR /&gt;ldmdb r1!, {r3-r11, lr} /* r3 contains CONTROL register. r4-r11 and LR restored. */&lt;BR /&gt;msr control, r3&lt;/P&gt;&lt;P&gt;tst lr, #0x10&lt;BR /&gt;ittt eq&lt;BR /&gt;vldmdbeq r1!, {s0-s16} /* s0-s16 contain hardware saved FP context. */&lt;BR /&gt;vstmiaeq r0!, {s0-s16} /* Copy hardware saved FP context on the task stack. */&lt;BR /&gt;vldmdbeq r1!, {s16-s31} /* Restore s16-s31. */&lt;/P&gt;&lt;P&gt;str r1, [r2] /* Save the location where the context should be saved next as the first member of TCB. */&lt;BR /&gt;bx lr&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I don't understand why it is S0~S&lt;FONT color="#FF0000"&gt;16&lt;/FONT&gt;?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;S0~S15 and status reg are pushed into stack by hardware, why copy it again?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Hope get your direction and advice！&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jul 2025 12:34:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2136881#M51111</guid>
      <dc:creator>LijieDu</dc:creator>
      <dc:date>2025-07-20T12:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M4F PendSV with FPU</title>
      <link>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2137345#M51133</link>
      <description>&lt;P&gt;&lt;SPAN class="HwtZe"&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;There seems to be an error in the code.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Could you please indicate where this code is taken from?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2025 10:39:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2137345#M51133</guid>
      <dc:creator>davidtosenovjan</dc:creator>
      <dc:date>2025-07-21T10:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M4F PendSV with FPU</title>
      <link>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2137775#M51162</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LijieDu_0-1753141549396.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/348648i9625467BF90FF6EB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LijieDu_0-1753141549396.png" alt="LijieDu_0-1753141549396.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hi davidtosenovjan&lt;/P&gt;&lt;P&gt;It comes from :&lt;A href="https://github.com/FreeRTOS/FreeRTOS-Kernel/tree/main/portable/IAR/ARM_CM4F_MPU" target="_blank"&gt;FreeRTOS-Kernel/portable/IAR/ARM_CM4F_MPU at main · FreeRTOS/FreeRTOS-Kernel · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope to get your advice, thanks very much&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jul 2025 23:48:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2137775#M51162</guid>
      <dc:creator>LijieDu</dc:creator>
      <dc:date>2025-07-21T23:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Cortex M4F PendSV with FPU</title>
      <link>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2138321#M51189</link>
      <description>&lt;P&gt;The code in the FreeRTOS-Kernel/portable/IAR/ARM_CM4F_MPU directory is maintained by Amazon.com, Inc.&lt;/P&gt;
&lt;P&gt;You can do so by opening an issue or a pull request on the GitHub repository. The FreeRTOS team actively monitors these channels.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jul 2025 10:45:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Cortex-M4F-PendSV-with-FPU/m-p/2138321#M51189</guid>
      <dc:creator>davidtosenovjan</dc:creator>
      <dc:date>2025-07-22T10:45:52Z</dc:date>
    </item>
  </channel>
</rss>

