it not really using syncronous channels as the data sheet states / you are just using both outputs of the same channel .. `
(i didnt need dead time .. but easy to add.. )
in anyevent here is a chunk of code that sets up TWO seperate channels (two differnt duty cycles )
if you want to just use channel outputs 5H & 5L rip out the "syncronous" stuff (channel 0 & channel 4)
(ALSO .. i didnt need dead time .. but easy to add.. )
void
PWM_setup ()
{
//PWM config
pmc_enable_periph_clk (ID_PWM);
PWMC_DisableChannel (PWM, PWM_CHANNEL_4);
PWMC_DisableChannel (PWM, PWM_CHANNEL_5);
PWMC_DisableChannel (PWM, PWM_CHANNEL_0);
PWMC_ConfigureClocks (pwm_clk, 0, VARIANT_MCK);
int ulPin = 8;
// Setup PWM for this pin {theta1}
PIO_Configure (g_APinDescription[ulPin].pPort,
g_APinDescription[ulPin].ulPinType,
g_APinDescription[ulPin].ulPin,
g_APinDescription[ulPin].ulPinConfiguration);
ulPin = 9;
// Setup PWM for this pin {thetaRB}
PIO_Configure (g_APinDescription[ulPin].pPort,
g_APinDescription[ulPin].ulPinType,
g_APinDescription[ulPin].ulPin,
g_APinDescription[ulPin].ulPinConfiguration);
//**pin44 {theta2}
PIO_Configure (g_APinC19RE_Description.pPort,
g_APinC19RE_Description.ulPinType,
g_APinC19RE_Description.ulPin,
g_APinC19RE_Description.ulPinConfiguration);
PWMC_ConfigureSyncChannel (PWM,
PWM_SCM_SYNC4 | PWM_SCM_SYNC5 | PWM_SCM_SYNC0
, PWM_SCM_UPDM_MODE1, 0, 0);
PWMC_SetPeriod (PWM, PWM_CHANNEL_4, pwm_period);
PWMC_SetPeriod (PWM, PWM_CHANNEL_5, pwm_period);
PWMC_ConfigureChannel (PWM, PWM_CHANNEL_4, PWM_CMR_CPRE_CLKA, 0,
PWM_CMR_CPOL);
PWMC_SetDutyCycle (PWM, PWM_CHANNEL_4, pwm_dutyRS);
PWMC_SetDutyCycle (PWM, PWM_CHANNEL_5, pwm_duty1);
PWMC_SetPeriod (PWM, PWM_CHANNEL_0, pwm_period);
PWMC_SetDutyCycle (PWM, PWM_CHANNEL_0, pwm_duty1);
PWMC_ConfigureChannel (PWM, PWM_CHANNEL_0, PWM_CMR_CPRE_CLKA, 0, 0);
PWM->PWM_OOV = PWM_OSSUPD_OSSUPH5;
PWMC_SetSyncChannelUpdatePeriod (PWM, 1);
PWMC_ConfigureComparisonUnit (PWM, PWM_CHANNEL_5, 1, 1);
PWMC_ConfigureComparisonUnit (PWM, PWM_CHANNEL_4, 1, 1);
PWMC_ConfigureEventLineMode (PWM, 0, PWM_ELMR_CSEL5 | PWM_ELMR_CSEL4);
PWMC_SetSyncChannelUpdateUnlock (PWM);
PWMC_EnableChannel (PWM, PWM_CHANNEL_0);
PWMC_SetSyncChannelUpdateUnlock (PWM);
}