こんにちは。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程度で切り替えてみたいです・ お遊びです
派生元のスレッドの小細工マクロを使って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_Dispatchstatic 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))#endifstatic 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_interrupt00000001 FD76E00F SAVE #0FH ← ここは無駄ですけれども ._LINE_TOP inline_asm00000005 7FA8 setpsw i00000007 7FA9 setpsw u00000009 6080 sub #8, sp0000000B 7EA1 push.l r10000000D FB12rrrrrrrr mov.l #_SuperLoopCurrentContextId, r100000013 CC11 mov.b [r1], r100000015 FD76C100 save r100000019 FD6AA2 mvfc isp, r20000001C E5200102 mov.l 4[r2], 8[sp]00000020 E5200001 mov.l 0[r2], 4[sp]00000024 6282 add #8, r200000026 FD682A mvtc r2, isp00000029 6211 add #1, r10000002B 6411 and #1, r10000002D FB22rrrrrrrr mov.l #_SuperLoopCurrentContextId, r200000033 C321 mov.b r1, [r2]00000035 FD76D100 rstr r100000039 7EB1 pop r10000003B 7F95 rte ._LINE_END inline_asm0000003D FD76F00F RSTR #0FH ← ここは実行されません00000041 7F95 RTE ← ここは実行されません