Other Parts Discussed in Thread: SYSCONFIG
Champs,
Customer is working on a very cost sensitive and space constrained application and trying to squeeze everything into a smaller package. We understand that ADC and COMP are supposed to use separate pins, however they tried multiplexing them on single pin and both seems to be functional. Questions:
1. Do we see any problems with such a use?
2. What those problems might be? anything to look out for? having gone through the collaterals I do not see anything that would prevent this from working (except Sysconfig doesn't let one do it, but everything works when done programmatically)
More specifically , they use PA27 (A0_0 and COMP0_IN0-) , ADC runs in sequence mode sampling several channels, including one shared with COMP, off VDDA as a reference (3.3V) and using DMA.
here is the config code they use:
static const DL_ADC12_ClockConfig gADC12_0ClockConfig = {
.clockSel = DL_ADC12_CLOCK_SYSOSC,
.divideRatio = DL_ADC12_CLOCK_DIVIDE_4,
.freqRange = DL_ADC12_CLOCK_FREQ_RANGE_24_TO_32,
};
DL_ADC12_reset(ADC12_0_INST);
DL_ADC12_enablePower(ADC12_0_INST);
DL_ADC12_setClockConfig(ADC12_0_INST, (DL_ADC12_ClockConfig *) &gADC12_0ClockConfig);
DL_ADC12_initSeqSample(ADC12_0_INST,
DL_ADC12_REPEAT_MODE_DISABLED, DL_ADC12_SAMPLING_SOURCE_AUTO, DL_ADC12_TRIG_SRC_SOFTWARE,
DL_ADC12_SEQ_START_ADDR_00, DL_ADC12_SEQ_END_ADDR_03, DL_ADC12_SAMP_CONV_RES_12_BIT,
DL_ADC12_SAMP_CONV_DATA_FORMAT_UNSIGNED);
DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_0,
DL_ADC12_INPUT_CHAN_2, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_1,
DL_ADC12_INPUT_CHAN_3, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_2,
DL_ADC12_INPUT_CHAN_7, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
DL_ADC12_configConversionMem(ADC12_0_INST, ADC12_0_ADCMEM_3,
DL_ADC12_INPUT_CHAN_0, DL_ADC12_REFERENCE_VOLTAGE_VDDA, DL_ADC12_SAMPLE_TIMER_SOURCE_SCOMP0, DL_ADC12_AVERAGING_MODE_DISABLED,
DL_ADC12_BURN_OUT_SOURCE_DISABLED, DL_ADC12_TRIGGER_MODE_AUTO_NEXT, DL_ADC12_WINDOWS_COMP_MODE_DISABLED);
DL_ADC12_setPowerDownMode(ADC12_0_INST,DL_ADC12_POWER_DOWN_MODE_MANUAL);
DL_ADC12_setSampleTime0(ADC12_0_INST,160);
DL_ADC12_enableDMA(ADC12_0_INST);
DL_ADC12_setDMASamplesCnt(ADC12_0_INST, 4);
DL_ADC12_enableDMATrigger(ADC12_0_INST, DL_ADC12_DMA_MEM3_RESULT_LOADED);
DL_ADC12_clearInterruptStatus(ADC12_0_INST,(DL_ADC12_INTERRUPT_DMA_DONE));
DL_ADC12_enableInterrupt(ADC12_0_INST,(DL_ADC12_INTERRUPT_DMA_DONE));
DL_ADC12_enableConversions(ADC12_0_INST);
Comparator init code:
/* Defines for COMP */
#define COMP_INST COMP0
#define COMP_INST_INT_IRQN COMP0_INT_IRQn
/* Defines for COMP DACCODE0 */
#define COMP_DACCODE0 (144)
/* GPIO configuration for COMP */
#define GPIO_COMP_IN0N_PORT (GPIOA)
#define GPIO_COMP_IN0N_PIN (DL_GPIO_PIN_27)
#define GPIO_COMP_IOMUX_IN0N (IOMUX_PINCM60)
#define GPIO_COMP_IOMUX_IN0N_FUNC (IOMUX_PINCM60_PF_UNCONNECTED)
/* COMP Initialization */
static const DL_COMP_Config gCOMPConfig = {
.channelEnable = DL_COMP_ENABLE_CHANNEL_NEG,
.mode = DL_COMP_MODE_ULP,
.negChannel = DL_COMP_IMSEL_CHANNEL_0,
.posChannel = DL_COMP_IPSEL_CHANNEL_0,
.hysteresis = DL_COMP_HYSTERESIS_20,
.polarity = DL_COMP_POLARITY_NON_INV
};
static const DL_COMP_RefVoltageConfig gCOMPVRefConfig = {
.mode = DL_COMP_REF_MODE_STATIC,
.source = DL_COMP_REF_SOURCE_VDDA_DAC,
.terminalSelect = DL_COMP_REF_TERMINAL_SELECT_POS,
.controlSelect = DL_COMP_DAC_CONTROL_SW,
.inputSelect = DL_COMP_DAC_INPUT_DACCODE0
};
DL_COMP_reset(COMP_INST);
DL_COMP_enablePower(COMP_INST);
delay_cycles(POWER_STARTUP_DELAY);
DL_COMP_init(COMP_INST, (DL_COMP_Config *) &gCOMPConfig);
DL_COMP_refVoltageInit(COMP_INST, (DL_COMP_RefVoltageConfig *) &gCOMPVRefConfig);
DL_COMP_setDACCode0(COMP_INST, COMP_DACCODE0);
DL_COMP_enableInterrupt(COMP_INST, (DL_COMP_INTERRUPT_OUTPUT_EDGE | DL_COMP_INTERRUPT_OUTPUT_EDGE_INV));
DL_COMP_enable(COMP_INST);
thank you,
Michael