This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28020: The DBRED value could not be load when CMPA value exceed TBPRD

Part Number: TMS320F28020

Hi Expert,

Customer has met the DBRED load issue as the below shown.

In the below figure, 

The green EPWM3A and blue EPWM2A are synchronous and have same TBPRD configuration, both are set 1 at ZERO moment and set 0 at CMPA up edge.

The differences of the two PWMs are the blue EPWM2A could be load DBRED value while the green EPWM3A  with no DB register setting; the blue EPWM2A  is set low when CBC event occurs while there is no action on green EPWM3A .

The purple wave will be low when the "EPwm1Regs.TZFLG.bit.CBC==1".

The yellow pulse means the CBC event which could trigger EPWM3A occur at that moment. The frequency of CBC event is 20kHz, while the ISR frequency is 27kHz.

As the picture shown, the EPWM2A is separated into 4 TB periods

The working conditions are:

# At the first period of EPWM2A, when the yellow CBC event pulse occur, the blue EPWM3A comes down.

# At the second period, the blue EPWM3A could load the DBRED rightly, however the CMPA value begins to be 1800 which is more than TBPRD=1333.

# At the third period, the EPWM3A keep high for the CMPA>TBPRD, and to be low when CBC event occur,

# At the 4th period, with "EPwm1Regs.TZFLG.bit.CBC==1" , the EPWM3A just set 1 at zero moment, but no DBRED delay

What we confused is that why the DBRED could not de loaded in 4th period, is this because the CMPA>TBPRD?

Is there a execution sequence of AQ, DB, TZ in time?

------------------------------------------------------------------------------------------------

The below is the PWM configuration code.

7484.PWM code.txt
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
The below is the PWM configuration code
// immediately load software force options
EPwm2Regs.AQSFRC.bit.RLDCSF = CC_LD_DISABLE;
//PWM_DISABLE
EPwm2Regs.AQCSFRC.bit.CSFA = AQ_CLEAR;
EPwm2Regs.AQCSFRC.bit.CSFB = AQ_CLEAR;
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE; // !!!!!
EPwm2Regs.TBPHS.half.TBPHS=0;
EPwm2Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm2Regs.TBCTL.bit.SYNCOSEL=TB_CTR_ZERO;
EPwm2Regs.TBCTL.bit.SWFSYNC = 0;//??????--???
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm2Regs.TBCTL.bit.PHSDIR = 0;//??????
EPwm2Regs.TBCTL.bit.FREE_SOFT = 3;//???????
// Period register -- Setup 50 kHz PWM frequency.
EPwm2Regs.TBPRD =1333;
// immediate write to write to compare register
//CC:
// setup compare for normal operation
//??CC--interleave to PWM1/PWM2A ?? PWM2B
EPwm2Regs.AQCTLA.bit.ZRO= AQ_SET;
EPwm2Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm2Regs.AQCTLB.bit.ZRO = AQ_SET;
EPwm2Regs.AQCTLB.bit.CBU= AQ_CLEAR;
// Compare register update control
//CC????
EPwm2Regs.CMPCTL.bit.LOADAMODE=CC_CTR_ZERO;
EPwm2Regs.CMPCTL.bit.LOADBMODE=CC_CTR_ZERO;
EPwm2Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
// set zero duty cycle
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thanks!

-Rayna

  • Rayna,

    Is there anything that could be changing the DBRED value? I see in the ISR that EPWM2's DBRED register is set = 0, can yous see if that line of code is having an unexpected affect?

    I don't think having TBPRD < CMPA would cause a DBRED value to be missed.

    Regards,
    Cody

  • Hi Cody,

    Thanks for reply.

    I also would like to check 1# if there is a execution sequence of AQ, DB, TZ in time?
    2# could TZFLG.CBC be automatically cleared when the ePWM time-base counter
    reaches zero (TBCTR = 0x0000)? However costumer said the TZFLG.CBC could not be automatically cleared which is the result they tested.

    The execution sequence is quite complex, I try to figure it out before I update here.

    Thanks!
    -Rayna
  • Rayna,

    The PWM is acted on as shown in the diagram below. From left to right, AQ then DB then PC then TZ.

    The CBC flag is cleared manually. The CBC trip is cleared automatically. Please see the following:

    Hope it helps.

    Regards,
    Cody 

  • Hi Cody,

    That's very useful. Thanks!

    -Rayna