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.

basic comparator operation - output comparison on COMP1OUT

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; 

  • Jaquier,

    Two things I might recommend:

    1. I notice that the comparator enable clock is not enabled ("SysCtrlRegs.PCLKCR3.bit.COMP1ENCLK = 1;    // COMP1 Enable ").  This must be done within EALLOW and EDIS.
    2. Check "Comp1Regs.COMPSTS.bit.COMPSTS" as the program is running in real-time mode.  This will enable you to see if the comparator output internally and allow you to see if the comparator is configured correctly and working as desired.  Once that works, you'll then need to work with the GPIO mux table to enable comp1out through the GPIO-01 pin.


    Thanks,
    Brett