Part Number: MSPM0G3519-Q1
Other Parts Discussed in Thread: SYSCONFIG
Tool/software:
Dear,
I have problems with the following case:
Picture below:
- pink : entry of comparator on COMP0
- yellow: reference on COMP0
- blue: output of COMP0
- green: signal that is not understood on ccp output.

Configuration: see next code
COMP0 is lead to capture CC2. With the configuraton below, I expect the output to follow the comparator. As you see, this is not happening (green).
- risng edge of comparator ZEROs the counter, falling edge of comparator causes capture.
- zero event will set the CCP2 output, capture event will reset the CCP2 output (blue in picture, but not correct).
COMP0 is also lead to capture CC3. With the configuraiton below, I expect the output to follow the comparator. The output is simularly not correct as well.
Same function, but signal on CCP3 output.
void Configure(Void)
{
static const DL_TimerA_ClockConfig gClockConfig =
{
.clockSel = DL_TIMER_CLOCK_BUSCLK,
.divideRatio = DL_TIMER_CLOCK_DIVIDE_1, // Runs half of 40MHz
.prescale = 0
};
DL_TimerA_reset(TIMA0);
DL_TimerA_enablePower(TIMA0);
delay_cycles(POWER_STARTUP_DELAY);
DL_TimerA_setClockConfig(TIMA0, (DL_TimerA_ClockConfig*)&gClockConfig);
DL_TimerA_setCounterMode(TIMA0, DL_TIMER_COUNT_MODE_UP);
DL_TimerA_setCounterValueAfterEnable(TIMA0, DL_TIMER_COUNT_AFTER_EN_ZERO);
//////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
// FIRST OUTPUT (H1 = PA15)
// Route COMP0 to CCP2 input
DL_TimerA_setCaptureCompareInput(TIMA0, DL_TIMER_CC_INPUT_INV_NOINVERT, DL_TIMER_CC_IN_SEL_COMP0, DL_TIMERA_CAPTURE_COMPARE_2_INDEX);
// Configure CCP2 to:
// - Zero on rising edge (reset timer)
// - Capture on falling edge
DL_TimerA_setCaptureCompareCtl(TIMA0, DL_TIMER_CC_MODE_CAPTURE, DL_TIMER_CC_ZCOND_TRIG_RISE | DL_TIMER_CC_ACOND_TIMCLK | DL_TIMER_CC_CCOND_TRIG_FALL, DL_TIMERA_CAPTURE_COMPARE_2_INDEX);
// Set CCP2 output behavior:
// - High on rising edge (ZERO event)
// - Low on falling edge (CAPTURE event)
DL_TimerA_setCaptureCompareAction(TIMA0, DL_TIMER_CC_ZACT_CCP_HIGH | DL_TIMER_CC_CUACT_CCP_LOW, DL_TIMERA_CAPTURE_COMPARE_2_INDEX);
/////
// SECOND OUTPUT (L2 = PA28)
// Route COMP0 to CCP3 input
DL_TimerA_setCaptureCompareInput(TIMA0, DL_TIMER_CC_INPUT_INV_NOINVERT, DL_TIMER_CC_IN_SEL_COMP0, DL_TIMERA_CAPTURE_COMPARE_3_INDEX);
// Configure CCP3 to:
// - Zero on rising edge (reset timer)
// - Capture on falling edge
DL_TimerA_setCaptureCompareCtl(TIMA0, DL_TIMER_CC_MODE_CAPTURE, /*DL_TIMER_CC_ZCOND_TRIG_RISE | */DL_TIMER_CC_ACOND_TIMCLK | DL_TIMER_CC_CCOND_TRIG_FALL, DL_TIMERA_CAPTURE_COMPARE_3_INDEX);
// Set CCP3 output behavior:
// - High on rising edge (ZERO event)
// - Low on falling edge (CAPTURE event)
DL_TimerA_setCaptureCompareAction(TIMA0, DL_TIMER_CC_ZACT_CCP_HIGH | DL_TIMER_CC_CUACT_CCP_LOW, DL_TIMERA_CAPTURE_COMPARE_3_INDEX);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The CCP2 and CCP3 lead to output pins
DL_TimerA_setCCPDirection(TIMA0, DL_TIMER_CC2_OUTPUT | DL_TIMER_CC3_OUTPUT);
// Configure counter control to load on CCP2 rising edge
DL_TimerA_setCounterControl(TIMA0, DL_TIMER_CZC_CCCTL2_ZCOND, DL_TIMER_CAC_CCCTL2_ACOND, DL_TIMER_CLC_CCCTL2_LCOND);
// Start TimerA0, TimerA1
DL_TimerA_startCounter(TIMA0);
DL_TimerA_enableClock(TIMA0);
// Configure 4 outputs
DL_GPIO_initPeripheralOutputFunction(GPIO_RXPAD_AR0_C3_IOMUX, GPIO_RXPAD_AR0_C3_IOMUX_FUNC);
DL_GPIO_enableOutput(GPIO_RXPAD_AR0_C3_PORT, GPIO_RXPAD_AR0_C3_PIN);
DL_GPIO_initPeripheralOutputFunction(GPIO_RXPAD_AR0_C2_IOMUX, GPIO_RXPAD_AR0_C2_IOMUX_FUNC);
DL_GPIO_enableOutput(GPIO_RXPAD_AR0_C2_PORT, GPIO_RXPAD_AR0_C2_PIN);
};
/* COMP_0 Initialization */
static const DL_COMP_Config gCOMP_0Config = {
.channelEnable = DL_COMP_ENABLE_CHANNEL_POS_NEG,
.mode = DL_COMP_MODE_FAST,
.negChannel = DL_COMP_IMSEL_CHANNEL_0,
.posChannel = DL_COMP_IPSEL_CHANNEL_2,
.hysteresis = DL_COMP_HYSTERESIS_30,
.polarity = DL_COMP_POLARITY_NON_INV
};
static const DL_COMP_RefVoltageConfig gCOMP_0VRefConfig = {
.mode = DL_COMP_REF_MODE_STATIC,
.source = DL_COMP_REF_SOURCE_NONE,
.terminalSelect = DL_COMP_REF_TERMINAL_SELECT_POS,
.controlSelect = DL_COMP_DAC_CONTROL_COMP_OUT,
.inputSelect = DL_COMP_DAC_INPUT_DACCODE0
};
void InitComp0(void)
{
DL_COMP_reset(COMP0);
DL_COMP_enablePower(COMP0);
delay_cycles(POWER_STARTUP_DELAY);
DL_COMP_init(COMP0, (DL_COMP_Config*)&gCOMP_0Config);
DL_COMP_refVoltageInit(COMP0, (DL_COMP_RefVoltageConfig*)&gCOMP_0VRefConfig);
DL_COMP_enableOutputFilter(COMP0, DL_COMP_FILTER_DELAY_70);
DL_COMP_enable(COMP0);
}
void init(void)
{
InitComp0();
Configure();
DL_GPIO_initPeripheralOutputFunction(GPIO_COMP_0_IOMUX_OUT, GPIO_COMP_0_IOMUX_OUT_FUNC); // show comparator output (blue)
}
Any advice what could be wrong in above code?
Thank you and best regards,
John
