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.

TMS320F28035: Question about COMP

Part Number: TMS320F28035

Dear team:

My customer want RAMPSTS to load the value of RAMPMAXREF as soon as COMPSTS is set.

But the debugging phenomenon is that after COMPSTS is set to 1, RAMPSTS will keep the count value unchanged, and will not continue to count until the next PWMSYNC arrives.

Is it a configuration problem in the following code?

    EALLOW;

    Comp1Regs.COMPCTL.bit.COMPDACEN = 1;

    Comp1Regs.RAMPMAXREF_SHDW = 0xfff0;
    Comp1Regs.RAMPDECVAL_SHDW = 0x0100;


    Comp1Regs.COMPCTL.bit.COMPSOURCE = 0;


    Comp1Regs.DACCTL.bit.DACSOURCE = 1;

    //PWMSYNC1 is the source sync    RAMPSOURCE+1
    Comp1Regs.DACCTL.bit.RAMPSOURCE = 0;

    Comp1Regs.DACCTL.bit.FREE_SOFT =0;

    // Synchronized value of comparator is passed through
    Comp1Regs.COMPCTL.bit.QUALSEL = 5;

    //0:Asynchronous version of Comparator output is passed
    //1:Synchronous version of Comparator output is passed
    Comp1Regs.COMPCTL.bit.SYNCSEL=0;


    Comp1Regs.COMPCTL.bit.CMPINV = 0;

    EDIS;

Best regards,

Green

  • Hi Green,

    Thank you for including the code. I will take a look through this and respond by tomorrow.

    Best Regards,

    Marlyn

  • Hi Green,

    But the debugging phenomenon is that after COMPSTS is set to 1, RAMPSTS will keep the count value unchanged, and will not continue to count until the next PWMSYNC arrives.

    I do not see any issues with the configuration attached. When you say "RAMPSTS will keep the count value unchanged" you mean that you don't see it go to the RAMPMAXREF value? Also, when it does count on the next PWMSYNC does it reset to RAMPMAXREF and start counting or does it continue to count from the previous value?

    Would it be possible to check the output of the comparator alongside the PWMSYNC pulse? For the PWMSYNC pulse you can just monitor the corresponding EPWM output. What is the PWMSYNCSEL bit of the HRPCTL register set to? By default PWMSYNC is generated by TBCTR = PRD pulse. If this is the case, please have an AQ action for when TBCTR=PRD. You could toggle the output when TBCTR=PRD. If you cannot change your configuration, you could setup another EPWM module with the same time-base settings and monitor that EPWM module in a scope.

    Best Regards,

    Marlyn

  • Hi Marlyn:

    you mean that you don't see it go to the RAMPMAXREF value?

    Yes, customer feedback that he doesn't see it go to the RAMPMAXREF, After COMPSTS changes to 1, continue single-step operation, RAMPSTS will keep the value counted before, and COMPSTS will keep 1 all the time; 

    Unlike that identified in the figure, RAMPSTS is set to RAMPMAXREF at the rising edge of COMPSTS, and COMPSTS is also set to 0 after several system cycles;

    EPwm1Regs.HRPCTL.bit.PWMSYNCSEL=0;

    PWMSYNC is generated when TBCTR = PRD, Sometimes in the next PWMSYNC, RAMPSTS will continue to decrease from the previous count value. Sometimes it starts counting from RAMPMAXREF;

    Change the start time of AQ from TBCTR=ZRO to TBCTR=PRD, and the results are the same.

    In addition, I don't understand the following paragraph you mentioned:

    Would it be possible to check the output of the comparator alongside the PWMSYNC pulse? For the PWMSYNC pulse you can just monitor the corresponding EPWM output.

    Best regards,

    Green

  • Hi Green,

    After COMPSTS changes to 1, continue single-step operation, RAMPSTS will keep the value counted before, and COMPSTS will keep 1 all the time; 

    Is COMPSTS always one after that? I wonder if the single-step operation is affecting the behavior. Could you run the application normally and monitor the expression window with the 'Continuous Refresh' enabled and see if the COMPSTS changes?

    Change the start time of AQ from TBCTR=ZRO to TBCTR=PRD, and the results are the same.

    Sorry I didn't mean to say that this would affect the operation. I meant that I would like to see the output on a scope. If (EPwm1Regs.HRPCTL.bit.PWMSYNCSEL=0;) then I would like to see a scope capture with a clear indication of the TBCTR=PRD event as well as the comparator output. You can setup the AQ action to toggle the output when TBCTR=PRD and check EPWMxA on the scope. 

    In the same scope capture, monitor COMP1OUT. If COMPSTS is always one, we should check COMP1OUT on the scope to confirm this behavior.

    Best Regards,

    Marlyn