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.

TMS570LS3137 N2HET Difference b/w ECMP and MCMP

Hi,

Can someone explain what is the difference between generating a PWM with ECMP and generating PWM with MCMP? I got different results with these two instructions.

  • Gobind,

    The biggest difference is that ECMP compares using '==' and MCMP uses '>=' but there could be more subtle side-effects depending on how you are generating your counter.   For example MCMP has a max difference between compare value and counter and wouldn't work well with a free running counter that rolls over.

    What difference are you seeing?

  • Anthony,

    Thanks for the reply. I was trying to generate a PWM with 50% duty cycle using MCMP in the following way:

    Counter Value = 4
    To get 50% duty cycle, i read two values 0 and 5 alternatively from the memory.
    When i read 0, i compare the counter value with 0 (i.e., 0>=0, 1>=0, 2>=0, 3>=0, 4>=0 etc using MCMP), since all the conditions are true, i should get a 100% duty cycle PWM.
    When i read 5, i compare the counter value with 5 (i.e., 0>=5, 1>=5, 2>=5, 3>=5, 4>=5 etc using MCMP), since all the conditions are false, i should get a 0% duty cycle PWM.
    Since I am reading these two values alternatively, i should get a PWM of 50% duty cycle.
    In the actual output, 100% duty cycle PWM was proper. But 0% duty cycle PWM was not as expected. In 0% PWM, the output remains low only for the first count and for the rest 4 counts it goes high. (counter starts from zero so total 5 counts).

    But, when i replaced MCMP with ECMP and made no other changes, it worked.

    For counter, i am using CNT instruction which means the counter rolls over.

  • Gobind,

    For that sort of PWM, try this program:

    Start   CNT { reg=A,comp=GE,max=10,data=0};
    L1   ECMP {next=START,hr_lr=LOW,angle_comp=OFF,en_pin_action=ON,cond_addr=L2,pin=0,action=PULSEHI,reg=A,data=5};
    L2   BR { next=START,cond_addr=START,event=NOCOND};

     

  • Anthony,

    Thanks. I understand that i can get 50% duty cycle with the program you suggested. But i have to actually generate a variable length PWM, and the length of the PWM depends on the data i read from the main memory. So finally, i have to combine the 0% PWM and 100% PWM to generate a variable length PWM with varying period.

  • Hi Gobind,

    What resolution do you need in setting the PWM period and duty cycle?

    And how many PWMs do you need simultaneously?

    We have a solution posted that can generate varialbe period and duty cycle PWMs at high resolution, but it can be complicated to understand.  So if you are happy with loop resolution there might be a simpler approach.  

  • Anthony,

    I have actually got the output which I needed by using ECMP instruction. But when i use MCMP instruction i do not get the same results. So, i just wanted to know the difference that why i do not get the required output with MCMP instruction. I have used the following code:

    L00   CNT { reg=A,max=4};
    L01   ECMP { en_pin_action=ON,pin=2,action=PULSEHI,reg=A,data=0,hr_data=64};
    L02   DJZ { next=L00,reqnum=0,request=GENREQ,cond_addr=S00,reg=A,data=4};
    S00   MOV32 { remote=0x6,type=REMTOREG,reg=A};
    S01   MOV32 { remote=0x1,type=REGTOREM,reg=A};
    S02   MOV32 { remote=0x2,type=IMTOREG&REM,reg=A,data=4};

    LR prescaler is 32. HR prescaler is 1. High Resolution Clock is 80MHz. VCLK is 160MHz.

    The memory location 0x6 is written using the HTU. The values read from the main memory using the HTU will either be 0% i.e., 5 or 100% i.e., 0. It can be like 0x0,0x0,0x0,0x5,0x5,0x0,0x5,0x5,0x5 etc. or any other sequence. So whatever duty cycle we want we should be getting it without changing the N2HET code. I will be happy to implement if i can get a simpler program that this.

    Thank you.

  • Hi Gobind,

    Were there any open items on this thread?  If not I'll close.

    If so please let me know.   The last post looked like you had what you needed but were just wanting to know ECMP v.s. MCMP which I think we covered.

     

  • Anthony,

    If that is the only difference, then we can close it. I will mark it as Verified.

    Thank you.