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.

CCS/TMS320F28377D: CMPSS comparator latch outputs won't clear

Part Number: TMS320F28377D


Tool/software: Code Composer Studio

I am trying to configure the comparator subsystem for ePWM trip based on some measured signals. I would like to use the latched outputs of the low and high comparators for the trip rather than using directly the digital filter output. There are two reasons why I would like to use the latched output:

1) The latched output does not automatically reset so there are no endless cycles of PWM enable-disable because the latched output will stay, well, latched.

2) I would like the ePWM to stay tripped until the user resets it after acknowledging a fault (for example an overcurrent).

Before writing code for fault flag generation, I wanted to check if the latched outputs behaved the way they were described in the Technical Reference Manual. I found that for the low-comparator the COMPLLATCH does not clear (to zero) even if I write 1 to LLATCHCLR during initialization, while for the high-comparator, COMPHLATCH does initialize to zero with HLATCHCLR set to 1 during initialization. The other problem I come across is not being able to reset either COMPHLATCH or COMPLLATCH through software by writing 1 to HLATCHCLR and LLATCHCLR, respectively.

The initialization code is pasted below. Please do note that the setting for CTRIPOUTHSEL and CTRIPHSEL (and also for the low-comparator) is set as 2 in the following code because I haven't changed the trip to latched output yet. I'm currently just testing the latched outputs by visualizing them.

Any help will be much appreciated.

void InitCMPSS1(void)
{
	// Initialise CMPSS1 (ADCINA2/CMPIN1P)

	EALLOW;
	// Comparator Control Register
	Cmpss1Regs.COMPCTL.bit.COMPDACE = 1;			// Enable Comparator/DAC
	Cmpss1Regs.COMPCTL.bit.ASYNCLEN = 0;			// Async comp output does not OR with latched digital filter output
	Cmpss1Regs.COMPCTL.bit.COMPLINV = 1;			// Output of low comparator is inverted
	Cmpss1Regs.COMPCTL.bit.COMPLSOURCE = 0;			// Inverting input of comparator driven by internal DAC
	Cmpss1Regs.COMPCTL.bit.ASYNCHEN = 0;			// Async comp output does not OR with latched digital filter output
	Cmpss1Regs.COMPCTL.bit.COMPHINV = 0;			// Output of high comparator is NOT inverted
	Cmpss1Regs.COMPCTL.bit.COMPHSOURCE = 0;			// Inverting input of comparator driven by internal DAC

	// Comparator Hysteresis Control Register
	Cmpss1Regs.COMPHYSCTL.bit.COMPHYS = 1;			// Set to TYPICAL hysteresis

	// High DAC Value Shadow Register
	Cmpss1Regs.DACHVALS.bit.DACVAL = TRIPLEVELHI;	// High DAC shadow threshold (90% of 4095)

	// Low DAC Value Shadow Register
	Cmpss1Regs.DACLVALS.bit.DACVAL = TRIPLEVELLO;	// Low DAC shadow threshold (10% of 4095)

	// Low Filter Control Register
	Cmpss1Regs.CTRIPLFILCTL.bit.SAMPWIN = 9;		// Filter sample window size
	Cmpss1Regs.CTRIPLFILCTL.bit.THRESH = 5;			// Filter majority voting threshold
	Cmpss1Regs.CTRIPLFILCLKCTL.bit.CLKPRESCALE = 1;	// Filter sample clock = SYSCLK
	Cmpss1Regs.CTRIPLFILCTL.bit.FILINIT = 1;		// Initialize all samples to filter input

	// High Filter Control Register
	Cmpss1Regs.CTRIPHFILCTL.bit.SAMPWIN = 9;		// Filter sample window size
	Cmpss1Regs.CTRIPHFILCTL.bit.THRESH = 5;			// Filter majority voting threshold
	Cmpss1Regs.CTRIPHFILCLKCTL.bit.CLKPRESCALE = 1;	// Filter sample clock = SYSCLK
	Cmpss1Regs.CTRIPHFILCTL.bit.FILINIT = 1;		// Initialize all samples to filter input

	// Set output signal paths
	Cmpss1Regs.COMPCTL.bit.CTRIPOUTHSEL = 2;		// Filter output drives CTRIPOUTH
	Cmpss1Regs.COMPCTL.bit.CTRIPOUTLSEL = 2;		// Filter output drives CTRIPOUTL
	Cmpss1Regs.COMPCTL.bit.CTRIPHSEL = 2;			// Filter output drives CTRIPH
	Cmpss1Regs.COMPCTL.bit.CTRIPLSEL = 2;			// Filter output drives CTRIPL

	// Reset output latch of digital filter
    Cmpss1Regs.COMPSTSCLR.bit.HLATCHCLR = 1;
    Cmpss1Regs.COMPSTSCLR.bit.LLATCHCLR = 1;

	EDIS;
}

  • In order for the EPMW module to stay tripped, you need to use the CBC mode of the TZ module.

    Pass your CMPSS signal through the EPWM XBAR, then inside the DC (Digital compare module) pass the signal through, inside the the TZ module enable the CBC switch for the DC signal, select what is the source for your LATCH clear signal.

    Inside the TZ module, select the event you would like to happen on the TZAU, TZBU, TZAD and TZBD.

    For your CMPSS questions, I am bringing in our CMPSS expert .

    Nima

  • Hi Shafiq,

    Based on your configuration code, you are inverting the output of the low comparator which comes before the latch. This means if the comparator output is low, the inverter output will be high and hence the latch will stay set even if you try to clear it. Did you intend to invert the output of the low comparator?

  • Thanks Nima and Frank for your inputs, appreciate it.

    Before following Nima's suggestion of setting up the TZ for CBC tripping, I would like to get the Cmpss working.

    Frank, thanks for looking into the configuration settings I uploaded. The output of the low comparator is inverted on purpose because I want the trip to be generated when the input CMPIN1P goes below DACLVALA (in terms of current measurement, it should generate a trip for me when the current exceeds a set limit in the negative direction). It is true that the latch is after the inverter, it is after the digital filter too, when I visualize the output of the digital filter COMPLSTS, it remains low; so I'd expect the latch should be in reset. But you are right that if initially the latch is set, it will remain set until it's manually reset. The problem I'm facing is that I'm unable to clear either the high latch (COMPHLATCH) or the low latch (COMPLLATCH) by writing 1 to HLATCHCLR and LLATCHCLR. Would you be able to advise where to go and find the reason for this strange behaviour?

  • Shafiq,

    The latchclr is EALLOW protected. Make sure whenever you write to the latchclr register, there is an EALLOW before hand.