3 phase generat using pwm (STM32F407-DISCOVERY )
Posted: Sun Jul 28, 2013 7:19 am
hi OlivierD
i am facing same kind of problem
did you get 3 phase out put?
am using chibios on STM32F4-Discovery board
trying to generate 3 phase using 6 PWM channel
but i can't get phase shift in each pair of CHx and CHxN (complementary)
if i configure 2 PWMConfig and put some delay in two respective pwmStart()
then i got phase shift between channels respected to 2 different PWMConfig
but don't understand how to get another phase shift . .
please help me . . .it's critical situation on my side . .
is it possible solution by change in TIMx_CCRx . ..
give me some idea phase shifting
i am facing same kind of problem
did you get 3 phase out put?
am using chibios on STM32F4-Discovery board
trying to generate 3 phase using 6 PWM channel
but i can't get phase shift in each pair of CHx and CHxN (complementary)
if i configure 2 PWMConfig and put some delay in two respective pwmStart()
then i got phase shift between channels respected to 2 different PWMConfig
but don't understand how to get another phase shift . .
please help me . . .it's critical situation on my side . .
Code: Select all
#include "ch.h"
#include "hal.h"
static PWMConfig pwmcfg1 = {
10000, // 10Khz PWM clock frequency
20000, // PWM period 1 second 200,* 50 Hz (20.0 ms) initial frequency
NULL, // No callback
{
{PWM_COMPLEMENTARY_OUTPUT_ACTIVE_LOW, NULL},
{PWM_COMPLEMENTARY_OUTPUT_ACTIVE_LOW, NULL},
{PWM_COMPLEMENTARY_OUTPUT_ACTIVE_LOW, NULL},
{PWM_OUTPUT_DISABLED, NULL},
},
0,
0
};
static PWMConfig pwmcfg2 = {
10000, /* 10Khz PWM clock frequency */
20000, /* PWM period 1 second */
NULL, /* No call back */
{
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_ACTIVE_HIGH, NULL},
{PWM_OUTPUT_DISABLED, NULL},
},
0,
0
};
int main(void)
{
halInit();
chSysInit();
/*for TIM1/2 PAL_MODE_ALTERNATE(n) = 1 */
palSetPadMode(GPIOE, 8, PAL_MODE_ALTERNATE(1));//TIM1, channel 1N
palSetPadMode(GPIOE, 10, PAL_MODE_ALTERNATE(1));//TIM1, channel 2N
palSetPadMode(GPIOE, 12, PAL_MODE_ALTERNATE(1));//TIM1, channel 3N
/* TIM8
* for TIM8/9/10/11 PAL_MODE_ALTERNATE(n) = 3 */
palSetPadMode(GPIOC, 6, PAL_MODE_ALTERNATE(3));//TIM8, channel 1
palSetPadMode(GPIOC, 7, PAL_MODE_ALTERNATE(3));//TIM8, channel 2
palSetPadMode(GPIOC, 8, PAL_MODE_ALTERNATE(3));//TIM8, channel 3
pwmStart(&PWMD1, &pwmcfg1);
pwmEnableChannel(&PWMD1, 0, 10000));
pwmEnableChannel(&PWMD1, 1, 10000);
pwmEnableChannel(&PWMD1, 2, 10000);
chThdSleepMilliseconds(500);
pwmStart(&PWMD8, &pwmcfg2);
pwmEnableChannel(&PWMD8, 0, 10000);
pwmEnableChannel(&PWMD8, 1, 10000);
pwmEnableChannel(&PWMD8, 2, 10000);
while (TRUE)
{
chThdSleepMilliseconds(5000);
}
}
is it possible solution by change in TIMx_CCRx . ..
give me some idea phase shifting