Hi All,
Greetings... I am new to this forum.
I am working on 320F28027 microcontroller based usb control stic for generating two pulse trains (C1 and C2) of variable frequency as shown in figure below. . I have generated this with epwm module but while updating the frequency it shows some jitter in channel C2 pulse width. I am new to this micro. and not very much familier with epwm. So any body suggest a scheme to generate such wave form using epwm module.
__ __
c1 | | | |
______| |___________________| |______________
__ __
c2 | | | |
_________________| |_____________________| |______________
Parameters:
1. C1 and C2 are at same frequency and variable from 1kHz to 100kHZ
2. Pulse width of C1 and C2 is 3.1uSec, It should be constant for the entire operating frequency range.
3.C1 and C2 are phase shifted by 180 Deg.
Thanks and regrads
toop
// Following are code i used to configure epwm and changing the frequency
===========================================
EPwm1Regs.TBPRD = 30000; // for 1kHz
EPwm1Regs.CMPA.half.CMPA = 180;
EPwm1Regs.CMPB=(30000-180);
EPwm1Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Master module
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm1Regs.TBCTL.bit.SYNCOSEL =TB_SYNC_DISABLE; // Sync down-stream module
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Set the clock rate
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; // Set the clock rate
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM1A on event A, up count
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM1A on event A, down count
EPwm1Regs.AQCTLB.bit.PRD = AQ_SET; // Set PWM1B on event B, up count
EPwm1Regs.AQCTLB.bit.CBD = AQ_CLEAR; // Clear PWM1B on event B, down count
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Symmetrical mode
=======================================
Code inside the ADC interrupt routine. Here it some time shows jitter in pulse width
// some computations according to ADC value and update the frequency as shown below
EPwm1Regs.CMPB = (pwm_period-180); // Keep the pulse width constant with changing period
EPwm1Regs.TBPRD = pwm_period; // Update new period
===========================