Etpu pwm api not working

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Etpu pwm api not working

927 Views
amey_murkute
Contributor III

Hello all,

          i am trying to use the "int32_t fs_etpu_pwm_init( uint8_t channel, uint8_t priority, uint32_t freq,
uint16_t duty, uint8_t polarity, uint8_t timebase, uint32_t timebase_freq) " api but it is not generating the pwm. So  further I started to debug the code & observed that the following case is not satisfying its condition.

if (eTPU->CHAN[channel].CR.B.CPBA == 0 )
{
/* get parameter RAM
number of parameters passed from eTPU C code */
pba = fs_etpu_malloc(FS_ETPU_PWM_NUM_PARMS);

if (pba == 0)
{
return (FS_ETPU_ERROR_MALLOC);
}
}
else /*set pba to what is in the CR register*/
{
pba=fs_etpu_data_ram(channel);
}

here in debug mode eTPU->CHAN[channel].CR.B.CPBA = 3 we are getting. 

& as well for the follwowing condition is also not satisfying

if ((chan_period == 0) || (chan_period > 0x007FFFFF ))
return( FS_ETPU_ERROR_FREQ);

/* write parameters to data memory */
*(pba + ((FS_ETPU_PWM_PERIOD_OFFSET - 1)>>2)) = chan_period;
*(pba + ((FS_ETPU_PWM_ACTIVE_OFFSET - 1)>>2)) =
(chan_period * duty) / 10000;

/* write channel configuration register */
eTPU->CHAN[channel].CR.R = (priority << 28) +
(FS_ETPU_PWM_TABLE_SELECT << 24) +
(FS_ETPU_PWM_FUNCTION_NUMBER << 16) +
(((uint32_t)pba - fs_etpu_data_ram_start)>>3);

/* write FM (function mode) bits */
eTPU->CHAN[channel].SCR.R = (timebase << 1) + polarity;

/* write hsr to start channel running */
eTPU->CHAN[channel].HSRR.R = FS_ETPU_PWM_INIT;

return(0);

Here we are getting chan_period = 0 & hence it is not executing any further part of the code. So please can you suggest any solution here.

Thanks.

0 Kudos
Reply
2 Replies

787 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, could you specify the device and used eTPU function set?

0 Kudos
Reply

787 Views
amey_murkute
Contributor III

   I am using MPC5777C controller & using following function. This function is used for only 10KHz pwm generation.

fs_etpu_pwm_init(resolver_channel,FS_ETPU_PRIORITY_MIDDLE,10000,5000,FS_ETPU_PWM_ACTIVEHIGH,FS_ETPU_TCR1,etpu_a_tcr1_freq);

& also I am using another etpu function to generate Space vector Modulation.

fs_etpu_pwmmac_update_svm(PWM_master_channel, (Voltage.xalpha * MI_factor), (Voltage.xbeta * MI_factor));

So is there any problem using different etpu function in same project? 

Thanks.

0 Kudos
Reply