Part Number: TMS320F28335
Hi everyone,
I'm trying to apply eQEP function working with my motor control code. I'm currently studying the example code Example_2833xEqep_pos_speed.
In this code, the unit timer is 10ms, but my control period is 0.1ms. Can I change the unit timer somehow for higher precision?
Also. The speed and angle calculation is motivated by an ePWM interrupt, But I'm not sure what's the interrupt period. Could it be synchronized with my controller which means the period is 0.1ms. I attached the ePWM setup code below.
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#include "Example_posspeed.h" // Example specific Include file
#if (CPU_FRQ_150MHZ)
#define CPU_CLK 150e6
#endif
#if (CPU_FRQ_100MHZ)
#define CPU_CLK 100e6
#endif
#define PWM_CLK 0 // 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;
}
Thanks,
Yang Sun