Hi,
I would like to perform a comparison between a 40kHz sinusoidal signal offset by 1.65V with a 1.65V DC signal. -> This means a zero crossing.
I want to output the result of the comparison on the COMP1OUT pin.
Below is the initialization of the comparator. I used a DACVAL for the reference signal 1.65V -> 512.
In the gpio init file, gpio1 is configured to be COMP1OUT (3)
the aio initialization is also ok.
I cannot observe any state change on the gpio1. Is there something else to do to connect the ouput of the comparator to the COMP1OUT pin ?
Thanks !
// Initialize Comp:
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1; // Enable Clock to the ADC
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Comparator shares the internal BG reference of the ADC, must be powered even if ADC is unused
SysCtrlRegs.PCLKCR3.bit.COMP1ENCLK = 1; // Enable clock to the Comparator 1 block
Comp1Regs.COMPCTL.bit.QUALSEL = 0; // Syncrhonized value is passed through
Comp1Regs.COMPCTL.bit.SYNCSEL = 0; // Asynchronous
Comp1Regs.COMPCTL.bit.CMPINV = 0; // Not inverted
Comp1Regs.COMPCTL.bit.COMPDACEN = 1; // Power up Comparator 1 locally
Comp1Regs.DACVAL.all = 512;
Comp1Regs.COMPCTL.bit.COMPSOURCE = 0;