I'm writing the same value to 4 PWM registers. The code which the compailer makes is not very sensful to me.
MOVW DP,#_Period
MOVL ACC,@_Period ; |191|
MOVW DP,#_EPwm3Regs+42
MOVL @_EPwm3Regs+42,ACC ; |191|
.dwpsn file "../source/Interrupt.c",line 192,column 2,is_stmt
MOVW DP,#_Period
MOVL ACC,@_Period ; |192|
MOVW DP,#_EPwm4Regs+42
MOVL @_EPwm4Regs+42,ACC ; |192|
.dwpsn file "../source/Interrupt.c",line 193,column 2,is_stmt
MOVW DP,#_Period
MOVL ACC,@_Period ; |193|
MOVW DP,#_EPwm5Regs+42
MOVL @_EPwm5Regs+42,ACC ; |193|
.dwpsn file "../source/Interrupt.c",line 194,column 2,is_stmt
MOVW DP,#_Period
MOVL ACC,@_Period ; |194|
MOVW DP,#_EPwm6Regs+42
MOVL @_EPwm6Regs+42,ACC ; |194|
Why it is always loading the same value to ACC? If the value in ACC is already correct why to load it again? I also tried to put this Period to temporay value.
MOVW DP,#_Period
MOVL ACC,@_Period ; |189|
MOVL *-SP[2],ACC ; |189|
.dwpsn file "../source/Interrupt.c",line 191,column 2,is_stmt
MOVL ACC,*-SP[2] ; |191|
MOVL @_EPwm3Regs+42,ACC ; |191|
.dwpsn file "../source/Interrupt.c",line 192,column 2,is_stmt
MOVW DP,#_EPwm4Regs+42
MOVL ACC,*-SP[2] ; |192|
MOVL @_EPwm4Regs+42,ACC ; |192|
.dwpsn file "../source/Interrupt.c",line 193,column 2,is_stmt
MOVW DP,#_EPwm5Regs+42
MOVL ACC,*-SP[2] ; |193|
MOVL @_EPwm5Regs+42,ACC ; |193|
.dwpsn file "../source/Interrupt.c",line 194,column 2,is_stmt
MOVW DP,#_EPwm6Regs+42
MOVL ACC,*-SP[2] ; |194|
MOVL @_EPwm6Regs+42,ACC ; |194|
Then I can reduce one cycle from every writing because now it is using -SP[2]. Period is defined as global but not volatile. I don't have any optimitzation. Should I have to make this more quickly? How to optimization goes with the CCS4? The options seems to be different from 3.3. I'm asking this because I have to write to 14 registers at this interrupt and this alone will take ~1us. It's quite a lot if running on 270kHz.