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.

CC2530: Using the analog comparator

Part Number: CC2530
Other Parts Discussed in Thread: Z-STACK, Z-STACK-ARCHIVE

Hi,

I am trying to activate the analog comparator in the CC2530. For some reason I can't get it to work. Any suggestions?

  • I'm using inputs P0_4 and P0_5.
  • I have set both as ADC input (APCFG bits 4 and 5).
  • I have enabled the comparator (set CMPCTL.EN to 1).
  • I have moved all other possible output from other peripherals to "alternative 2" positions.
  • I removed pullups/downs (P0INP = 0xFF)
  • Though it should not be needed, I also have set P0_4 and P0_5 as inputs

Just applying 2 voltage levels to the inputs, I can not get the output (CMPCTL.OUTPUT) to change.

What am I missing? 

  • Hi Han,

    It appears you've followed all instructions from Chapter 19 of the TRM.  Have you confirmed the basic analog functionality of these pins?  Are you using a RF protocol stack which could be initializing and utilizing these pins for some other purpose?

    Regards,
    Ryan

  • Reading through the manual again, I read the following (section 1.1.3.):

    The comparator output is mapped into the digital I/O port and can be treated by the MCU as a regular digital input.

    This not clear from the picture in 19.1. Which port is meant? Is this only true for the interrupt handling?


    I still did not solve my problem yet. Could not find any problem or interference with z-stack 1.2.

  • The analog comparator output is only available for internal use, either by reading or interrupt handling.  I also cannot see any use for P0.4 and P0.5 in the Z-STACK-ARCHIVE HA 1.2 stack.  Can you further debug the register values to ensure that the pin and comparator settings are correctly set?  What hardware are you using and are you applying voltage directly to the pins?

    Regards,
    Ryan

  • I'm very sorry having bothered you. I was a very very stupid issue. The input connections were shifted one place  (so connecting to P0-3 and p0_4).

    It's working as expected now. Thanks for you time.