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
  • 思い浮かんだコードの断片のネタ(ネタの状態ですので動作は試していません)

    単に2つのスーパーループを切り替えるだけでもSAVE命令とRSTR命令にゴテゴテとコードが付加されて行きます、、、

    uint8_t SuperLoopCurrentContextId = 0;

    #if 0 /* Unfortunately CC-RX doesn't allow multiple #pragma for one function. */
    #pragma interrupt r_Config_CMT3_cmi3_interrupt(vect=VECT(PERIB,INTB129))
    #endif
    #pragma inline_asm r_Config_CMT3_cmi3_interrupt
    void r_Config_CMT3_cmi3_interrupt(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
    }

     

Reply
  • 思い浮かんだコードの断片のネタ(ネタの状態ですので動作は試していません)

    単に2つのスーパーループを切り替えるだけでもSAVE命令とRSTR命令にゴテゴテとコードが付加されて行きます、、、

    uint8_t SuperLoopCurrentContextId = 0;

    #if 0 /* Unfortunately CC-RX doesn't allow multiple #pragma for one function. */
    #pragma interrupt r_Config_CMT3_cmi3_interrupt(vect=VECT(PERIB,INTB129))
    #endif
    #pragma inline_asm r_Config_CMT3_cmi3_interrupt
    void r_Config_CMT3_cmi3_interrupt(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
    }

     

Children
No Data