Thanks, @Tahamid. I already know your blog; it provides us with so much valuable information. This time, I want to express my appreciation and gratitude for sharing your knowledge with the world through the blog .
I am able to work with DMA to feed the PWM duty cycle, and it works well for the first half cycle. I am confused about how to feed data for the next half cycle. Do I need a 180-degree phase-shifted sine wave array value, or can I change the polarity of the main PWM channels? What is the generic logic for this?
I used center-aligned mode based on some sites that mention its advantages, by the way I don't have a specific reason for choosing it.
i just showing my code for the array to pwm by DMA as follows
const uint16_t sine_table[200]= {250, 250, 250, 249, 249, 248, 248, 247, 246, 245, 244, 243, 241, 240,
238, 236, 235, 233, 231, 228, 226, 224, 221, 219, 216, 213, 211, 208, 205, 202, 198, 195, 192,
189, 185, 182, 178, 175, 171, 167, 164, 160, 156, 152, 148, 145, 141, 137, 133, 129, 125, 121,
117, 113, 109, 105, 102, 98, 94, 90, 86, 83, 79, 75, 72, 68, 65, 61, 58, 55, 52, 48, 45, 42, 39,
37, 34, 31, 29, 26, 24, 22, 19, 17, 15, 14, 12, 10, 9, 7, 6, 5, 4, 3, 2, 2, 1, 1, 0, 0, 0, 1, 1,
2, 2, 2, 3, 3, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 19, 22, 24, 26, 29, 31, 34, 37, 39, 42, 45, 48,
52, 55, 58, 61, 65, 68, 72, 75, 79, 83, 86, 90, 94, 98, 102, 105, 109, 113, 117, 121, 125, 129, 133,
137, 141, 145, 148, 152, 156, 160, 164, 167, 171, 175, 178, 182, 185, 189, 192, 195, 198, 202, 205,
208, 211, 213, 216, 219, 221, 224, 226, 228, 231, 233, 235, 236, 238, 240, 241, 243, 244, 245, 246,
247, 248, 248, 249, 249, 250, 250, 250};
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)sine_table, 20);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_2, (uint32_t *)sine_table, 20);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);
Am trying to give same half wave array to get the next half cycle .