Hi everyone,
I'm new to the micro controller. Currently I'm trying to understand the Example_2833xEqep_pos_speed from the TI control SUITE which I need to apply on a PMSM control. I'm stuck with the interrupt triggered by the ePWM, my code is like below:
#if (CPU_FRQ_150MHZ)
#define CPU_CLK 150e6
#endif
#if (CPU_FRQ_100MHZ)
#define CPU_CLK 100e6
#endif
#define PWM_CLK 5e3 // 5kHz (300rpm) EPWM1 frequency. Freq. can be changed here
#define SP CPU_CLK/(2*PWM_CLK)
#define TBCTLVAL 0x200E // up-down count, timebase=SYSCLKOUT
void initEpwm()
{
EPwm4Regs.ETSEL.all=0x0A; // Interrupt on PRD
EPwm4Regs.ETPS.all=1;
EPwm4Regs.ETFLG.all=0;
EPwm4Regs.ETCLR.all=0;
EPwm4Regs.ETFRC.all=0;
EPwm4Regs.PCCTL.all=0;
EPwm4Regs.TBCTL.all=0x0010+TBCTLVAL; // Enable Timer
EPwm4Regs.TBPRD=SP;
}
I'm not pretty sure how long the time interval between two interrupts would be based on the two registers I marked as red and If I want to calculate the speed and position every 0.1 ms what values should I change to.
Thanks,
Yang Sun