How to for loop question??
I have what I am sure to most a simple C question (I'm a hardware guy at this end).....
For brevity I would like to take the following statements and combine them using 1 for loop but don't know the semantics on how to do this....I am using the HAL library with CubeMX:
TIM2->CCR1 = pwmPulse[speed] - HAPTIC_PW;
TIM2->CCR2 = pwmPulse[speed] - HAPTIC_PW;
TIM2->CCR3 = pwmPulse[speed] - HAPTIC_PW;
TIM2->CCR4 = pwmPulse[speed] - HAPTIC_PW;Below is a FAILED attempt:
for (uint8_t i = 0; i < 4; i++)
{
TIM2->(CCR1 + i) = pwmPulse[speed] - HAPTIC_PW;
}Thanks for the help
