AnsweredAssumed Answered

PWM External Sync

Question asked by BlueIceScream on Oct 26, 2015
Latest reply on Dec 14, 2015 by Prashant

Hi,

I have several devices (based on BF518F). One of them master and other slaves. Master must provide PWM sync to slaves. I perform this steps

 

On master:

 

1. Init PWM (Freq 20KHz)

2. Set PWM_SYNC like output

3. Send "start" pulse on GPIO pin (used by slaves to adjust PWM duties and enable Output Gate)

 

[code]

#define PWM_NUM                              (0)

#define PWM_MOD_FREQUENCY       (50)

#define PWM_FREQUENCY                 (20000)

#define PWM_DEAD_TIME                   (150)

#define PWM_SYNC_WIDTH                (200)


adi_pwm_SetUpdateMode(PWMHandle, ADI_PWM_UPDATE_SINGLE);

adi_pwm_EnableTripInput(PWMHandle, false);

adi_pwm_SetPolarity(PWMHandle, ADI_PWM_POL_HIGH);

adi_pwm_SetDeadTime(PWMHandle, fsclk, PWM_DEAD_TIME);

adi_pwm_SetPeriod(PWMHandle, fsclk, PWM_FREQUENCY);

adi_pwm_SetSyncPulseWidth(PWMHandle, fsclk, PWM_SYNC_WIDTH);

adi_pwm_EnableCrossOver(PWMHandle, ADI_PWM_CHANNEL_A, false);

adi_pwm_EnableCrossOver(PWMHandle, ADI_PWM_CHANNEL_B, false);

adi_pwm_EnableCrossOver(PWMHandle, ADI_PWM_CHANNEL_C, false);

adi_pwm_EnableChannel(PWMHandle, ADI_PWM_CHANNEL_A, ADI_PWM_SIDE_BOTH, false);

adi_pwm_EnableChannel(PWMHandle, ADI_PWM_CHANNEL_B, ADI_PWM_SIDE_BOTH, false);

adi_pwm_EnableChannel(PWMHandle, ADI_PWM_CHANNEL_C, ADI_PWM_SIDE_BOTH, false);

adi_pwm_EnableInterrupt(PWMHandle, ADI_PWM_INTERRUPT_SYNC, true);

adi_pwm_RegisterCallback(PWMHandle, callback, (void *) 0);

[/code]

 

 

On slave

1. Init PWM (Freq 20KHz, Enable Sync interrupt for changing duties)

2. Disable Output Gate and start PWM

2. Set PWM_SYNC like input

3. Set PWM_SYNC pin asynchronous

4. Wait before Master send "start" pulse

5. Adjust PWM duties and enable Output Gate

 

[code]

adi_pwm_SetUpdateMode(PWMHandle, ADI_PWM_UPDATE_SINGLE);

adi_pwm_EnableTripInput(PWMHandle, false);

adi_pwm_SetPolarity(PWMHandle, ADI_PWM_POL_HIGH);

adi_pwm_SetDeadTime(PWMHandle, fsclk, PWM_DEAD_TIME);

adi_pwm_SetPeriod(PWMHandle, fsclk, PWM_FREQUENCY);

adi_pwm_SetSyncPulseWidth(PWMHandle, fsclk, PWM_SYNC_WIDTH);

adi_pwm_EnableCrossOver(PWMHandle, ADI_PWM_CHANNEL_A, false);

adi_pwm_EnableCrossOver(PWMHandle, ADI_PWM_CHANNEL_B, false);

adi_pwm_EnableCrossOver(PWMHandle, ADI_PWM_CHANNEL_C, false);

adi_pwm_EnableChannel(PWMHandle, ADI_PWM_CHANNEL_A, ADI_PWM_SIDE_BOTH, false);

adi_pwm_EnableChannel(PWMHandle, ADI_PWM_CHANNEL_B, ADI_PWM_SIDE_BOTH, false);

adi_pwm_EnableChannel(PWMHandle, ADI_PWM_CHANNEL_C, ADI_PWM_SIDE_BOTH, false);

adi_pwm_EnableInterrupt(PWMHandle, ADI_PWM_INTERRUPT_SYNC, true);

adi_pwm_SetSyncSource(PWMHandle, ADI_PWM_SYNC_EXTERNAL);

adi_pwm_SetSyncSelect(PWMHandle, ADI_PWM_SYNC_ASYNCHRONOUS);

 

[/code]

 

Oscilloscope shows PWM outputs (i use one channel from every device) not synchronized. The delay between slaves' outputs not constant value (after device reboot it changes to another).

 

So... need help)

Outcomes