RXv3コアのレジスタ一括退避機能を使ってマルチスーパーループ実行ライブラリ(MultiSuperLoopExecLibrary)を作ってみるスレッド

こんにちは。NoMaYです。

今、以下のスレッドに投稿しているのですけれども、派生ネタが思い浮かびましたので、またひとつ立ててみました。

RXv3コアのレジスタ一括退避機能の使い方(Register Bank Save Function Usage)を調べてみるスレッド
community-ja.renesas.com/cafe_rene/forums-groups/mcu-mpu/rx/f/forum5/9572/rxv3-register-bank-save-function-usage

派生ネタ

・ スーパーループを複数同時実行する(複数のスーパーループを切り替えながら実行する)、という、ありがちなものです
・ RXv3コアのレジスタ一括退避機能の高速性を鑑みて10μsec程度で切り替えてみたいです
・ お遊びです

Parents
  • 派生元のスレッドの小細工マクロを使ってRXスマートコンフィグレータのCGコンポーネントのユーザ記述部にコードを押し込む案が思い浮かびました。(レジスタ一括退避バンクを1つとクロックを1クロックを無駄に使いますけれども。)

    ソース:

    /* Start user code for include. Do not edit comment generated here */

    #include "r_rx_nested_interrupt/r_rx_nested_interrupt.h"

    /* End user code. Do not edit comment generated here */

     

    /* Start user code for global. Do not edit comment generated here */

    uint8_t SuperLoopCurrentContextId = 0;

    #pragma inline_asm MultiSuperLoop_Dispatch
    static void MultiSuperLoop_Dispatch(void)
    {
        /* Re-enable interrupt. */
        setpsw i

        /* Save the current super loop context. Be aware that the USP is used from now. */
        /* (As of today, the DPFPU registers are neither saved nor restored.) */
        setpsw u
        sub #8, sp
        push.l r1
        mov.l #_SuperLoopCurrentContextId, r1
        mov.b [r1], r1
        save r1

        /* Move PSW, PC from the interrupt stack to the current super loop's user stack. */
        mvfc isp, r2
        mov.l 4[r2], 8[sp]
        mov.l 0[r2], 4[sp]
        add #8, r2
        mvtc r2, isp

        /* Select the next super loop. */
        add #1, r1
        and #1, r1
        mov.l #_SuperLoopCurrentContextId, r2
        mov.b r1, [r2]

        /* Restore the next super loop context. Be aware that the USP is used here. */
        /* (As of today, the DPFPU registers are neither saved nor restored.) */
        rstr r1
        pop r1
        rte
    }

    #define r_Config_CMT3_cmi3_interrupt(...) R_CG_ATTRIB_INTERRUPT_BANK(r_Config_CMT3_cmi3_interrupt, MY_BSP_CFG_REG_BANK_SCRATCH, __VA_ARGS__)

    /* End user code. Do not edit comment generated here */

     

    #if FAST_INTERRUPT_VECTOR == VECT_PERIB_INTB129
    #pragma interrupt r_Config_CMT3_cmi3_interrupt(vect=VECT(PERIB,INTB129),fint)
    #else
    #pragma interrupt r_Config_CMT3_cmi3_interrupt(vect=VECT(PERIB,INTB129))
    #endif
    static void r_Config_CMT3_cmi3_interrupt(void)
    {
        /* Start user code for r_Config_CMT3_cmi3_interrupt. Do not edit comment generated here */

        MultiSuperLoop_Dispatch();

        /* End user code. Do not edit comment generated here */
    }

     
    リスト:

    00000001                         __$r_Config_CMT3_cmi3_interrupt:
                                            .STACK  __$r_Config_CMT3_cmi3_interrupt=8
                                            .RVECTOR    129,__$r_Config_CMT3_cmi3_interrupt
    00000001 FD76E00F                       SAVE #0FH ← ここは無駄ですけれども
                                            ._LINE_TOP  inline_asm
    00000005 7FA8                        setpsw i
    00000007 7FA9                        setpsw u
    00000009 6080                        sub #8, sp
    0000000B 7EA1                        push.l r1
    0000000D FB12rrrrrrrr                mov.l #_SuperLoopCurrentContextId, r1
    00000013 CC11                        mov.b [r1], r1
    00000015 FD76C100                    save r1
    00000019 FD6AA2                      mvfc isp, r2
    0000001C E5200102                    mov.l 4[r2], 8[sp]
    00000020 E5200001                    mov.l 0[r2], 4[sp]
    00000024 6282                        add #8, r2
    00000026 FD682A                      mvtc r2, isp
    00000029 6211                        add #1, r1
    0000002B 6411                        and #1, r1
    0000002D FB22rrrrrrrr                mov.l #_SuperLoopCurrentContextId, r2
    00000033 C321                        mov.b r1, [r2]
    00000035 FD76D100                    rstr r1
    00000039 7EB1                        pop r1
    0000003B 7F95                        rte
                                            ._LINE_END  inline_asm
    0000003D FD76F00F                       RSTR #0FH ← ここは実行されません
    00000041 7F95                           RTE ← ここは実行されません

     

Reply
  • 派生元のスレッドの小細工マクロを使ってRXスマートコンフィグレータのCGコンポーネントのユーザ記述部にコードを押し込む案が思い浮かびました。(レジスタ一括退避バンクを1つとクロックを1クロックを無駄に使いますけれども。)

    ソース:

    /* Start user code for include. Do not edit comment generated here */

    #include "r_rx_nested_interrupt/r_rx_nested_interrupt.h"

    /* End user code. Do not edit comment generated here */

     

    /* Start user code for global. Do not edit comment generated here */

    uint8_t SuperLoopCurrentContextId = 0;

    #pragma inline_asm MultiSuperLoop_Dispatch
    static void MultiSuperLoop_Dispatch(void)
    {
        /* Re-enable interrupt. */
        setpsw i

        /* Save the current super loop context. Be aware that the USP is used from now. */
        /* (As of today, the DPFPU registers are neither saved nor restored.) */
        setpsw u
        sub #8, sp
        push.l r1
        mov.l #_SuperLoopCurrentContextId, r1
        mov.b [r1], r1
        save r1

        /* Move PSW, PC from the interrupt stack to the current super loop's user stack. */
        mvfc isp, r2
        mov.l 4[r2], 8[sp]
        mov.l 0[r2], 4[sp]
        add #8, r2
        mvtc r2, isp

        /* Select the next super loop. */
        add #1, r1
        and #1, r1
        mov.l #_SuperLoopCurrentContextId, r2
        mov.b r1, [r2]

        /* Restore the next super loop context. Be aware that the USP is used here. */
        /* (As of today, the DPFPU registers are neither saved nor restored.) */
        rstr r1
        pop r1
        rte
    }

    #define r_Config_CMT3_cmi3_interrupt(...) R_CG_ATTRIB_INTERRUPT_BANK(r_Config_CMT3_cmi3_interrupt, MY_BSP_CFG_REG_BANK_SCRATCH, __VA_ARGS__)

    /* End user code. Do not edit comment generated here */

     

    #if FAST_INTERRUPT_VECTOR == VECT_PERIB_INTB129
    #pragma interrupt r_Config_CMT3_cmi3_interrupt(vect=VECT(PERIB,INTB129),fint)
    #else
    #pragma interrupt r_Config_CMT3_cmi3_interrupt(vect=VECT(PERIB,INTB129))
    #endif
    static void r_Config_CMT3_cmi3_interrupt(void)
    {
        /* Start user code for r_Config_CMT3_cmi3_interrupt. Do not edit comment generated here */

        MultiSuperLoop_Dispatch();

        /* End user code. Do not edit comment generated here */
    }

     
    リスト:

    00000001                         __$r_Config_CMT3_cmi3_interrupt:
                                            .STACK  __$r_Config_CMT3_cmi3_interrupt=8
                                            .RVECTOR    129,__$r_Config_CMT3_cmi3_interrupt
    00000001 FD76E00F                       SAVE #0FH ← ここは無駄ですけれども
                                            ._LINE_TOP  inline_asm
    00000005 7FA8                        setpsw i
    00000007 7FA9                        setpsw u
    00000009 6080                        sub #8, sp
    0000000B 7EA1                        push.l r1
    0000000D FB12rrrrrrrr                mov.l #_SuperLoopCurrentContextId, r1
    00000013 CC11                        mov.b [r1], r1
    00000015 FD76C100                    save r1
    00000019 FD6AA2                      mvfc isp, r2
    0000001C E5200102                    mov.l 4[r2], 8[sp]
    00000020 E5200001                    mov.l 0[r2], 4[sp]
    00000024 6282                        add #8, r2
    00000026 FD682A                      mvtc r2, isp
    00000029 6211                        add #1, r1
    0000002B 6411                        and #1, r1
    0000002D FB22rrrrrrrr                mov.l #_SuperLoopCurrentContextId, r2
    00000033 C321                        mov.b r1, [r2]
    00000035 FD76D100                    rstr r1
    00000039 7EB1                        pop r1
    0000003B 7F95                        rte
                                            ._LINE_END  inline_asm
    0000003D FD76F00F                       RSTR #0FH ← ここは実行されません
    00000041 7F95                           RTE ← ここは実行されません

     

Children
No Data