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.

Analog Comparator on TM4C1294KCPT

Other Parts Discussed in Thread: LM339

I created the Initial code with the pin Mux tool.

I need the analog comparator 0-2. But this comparator definition I cannot be find in the file pin_map.h. I use TivaWare_C_Series-2.1.0.12573.

The Pin Mux Tool create this code:

   //
    // Enable pin PC7 for COMP0 C0-
    //
    MAP_GPIOPinConfigure(GPIO_PC7_C0-);
    MAP_GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_7);

    //
    // Enable pin PL2 for COMP0 C0O
    //
    MAP_GPIOPinConfigure(GPIO_PL2_C0O);
    MAP_GPIOPinTypeComparator(GPIO_PORTL_BASE, GPIO_PIN_2);

    //
    // Enable pin PC6 for COMP0 C0+
    //
    MAP_GPIOPinConfigure(GPIO_PC6_C0+);
    MAP_GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_6);

    //
    // Enable pin PL3 for COMP1 C1O
    //
    MAP_GPIOPinConfigure(GPIO_PL3_C1O);
    MAP_GPIOPinTypeComparator(GPIO_PORTL_BASE, GPIO_PIN_3);

    //
    // Enable pin PC4 for COMP1 C1-
    //
    MAP_GPIOPinConfigure(GPIO_PC4_C1-);
    MAP_GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_4);

    //
    // Enable pin PC5 for COMP1 C1+
    //
    MAP_GPIOPinConfigure(GPIO_PC5_C1+);
    MAP_GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_5);

    //
    // Enable pin PP0 for COMP2 C2+
    //
    MAP_GPIOPinConfigure(GPIO_PP0_C2+);
    MAP_GPIOPinTypeComparator(GPIO_PORTP_BASE, GPIO_PIN_0);

    //
    // Enable pin PP1 for COMP2 C2-
    //
    MAP_GPIOPinConfigure(GPIO_PP1_C2-);
    MAP_GPIOPinTypeComparator(GPIO_PORTP_BASE, GPIO_PIN_1);

    //
    // Enable pin PD2 for COMP2 C2O
    //
    MAP_GPIOPinConfigure(GPIO_PD2_C2O);
    MAP_GPIOPinTypeComparator(GPIO_PORTD_BASE, GPIO_PIN_2);

In the pin_map.h I find only this settings for my uP:


#define GPIO_PC4_U7RX           0x00021001
#define GPIO_PC4_T7CCP0         0x00021003
#define GPIO_PC4_EPI0S7         0x0002100F

#define GPIO_PC5_U7TX           0x00021401
#define GPIO_PC5_T7CCP1         0x00021403
#define GPIO_PC5_RTCCLK         0x00021407
#define GPIO_PC5_EPI0S6         0x0002140F

#define GPIO_PC6_U5RX           0x00021801
#define GPIO_PC6_EPI0S5         0x0002180F

#define GPIO_PC7_U5TX           0x00021C01
#define GPIO_PC7_EPI0S4         0x00021C0F

The problem are only the comparator Inputs. Comparator outputs are defined in pin_map.h.

Where is the problem? Do I have to write the specification myself or is there another problem somewhere?

Hope somebody has an answer or a hint how to do it.

Best regards

Franz

  • Those (missing/awol) comparator pins are "analog" - are they not?       At least in the past - under StellarisWare - only the comparator outputs (just as you report) appeared.

    Here's what has (long) worked for my small tech firm:


            ROM_GPIOPinConfigure(GPIO_PF0_C0O); //  Comp Output

            ROM_GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7);                    

    Note that - like you - we could only "pin configure" the comparator's output.    (as it is treated as a digital pin)     Analog pins seem quite happy/content w/simple, "pin type."

    Perhaps the manual should better define just what is encompassed w/in "pin_map.h"

    Believe this should place your comparators, "On the Air!" thus fulfilling your "hope."

  • Hello cb1

    Unlocking the PF0 pin sequence must be done!!!

    Regards
    Amit
  • Hi Amit,

    As I've written here (many times) we ARE aware of PF0. Poster's issue was covered in my post - and he's not using PF0. I stand by the code I presented - would even wager (again) 10 USD! (and then - never/ever be able to "slam my wallet shut!")
  • Hello cb1,

    Yes indeed. It was more for the poster to note that if they use PF0 was to note the Locked Pin. We know PF0 is documented more than anything on the forum, but still to be cautious about.

    Regards
    Amit
  • Dear Amit
    I ask you again, how the comparator Inputs (Comp 0 PC6,7; Comp1 PC4,5; Comp 2 PP0,1) must be defined, they are workking as Comparator Inputs. If possible, please send me a small piece of code with the initialisation of comparator input pins. My real problem is: I have to design a new hardware.
    Thank you for your replay
    Best regards
    Franz
  • Hi Amit,

    Poster's display of thanks overwhelms.     "Silver platter" service - so "common" these days - appears (not) to have budged his needle...

  • Hello Franz,

    cb1's post has the answer defined

    GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7);

    should do the required

    Regards
    Amit
  • Thank you Amit.

    Now it is working:

    This is my working code for all 3 comparator's I use open drain outputs:

    /**********************************************************************
      function ComparatorInit
      input   :  --
      output  :  --
      purpose : Comparator Init
      call    : Init
    ***********************************************************************/
    void ComparatorInit(void)
    {
        // Enable Comparator Input Port C
        MAP_GPIOPinTypeComparator(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7);
        // Enable Comparator Input Port P
        MAP_GPIOPinTypeComparator(GPIO_PORTP_BASE, GPIO_PIN_0 | GPIO_PIN_1);

        // Enable pin PD0 for COMP0 C0O
        // Enable pin PL3 for COMP1 C1O
        // Enable pin PD2 for COMP2 C2O
        MAP_GPIOPinConfigure(GPIO_PD0_C0O);
        MAP_GPIOPinConfigure(GPIO_PD1_C1O);
        MAP_GPIOPinConfigure(GPIO_PD2_C2O);
        MAP_GPIODirModeSet(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, GPIO_DIR_MODE_HW);
        MAP_GPIOPadConfigSet(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
        
        MAP_ComparatorRefSet(COMP_BASE,    COMP_REF_OFF);

        MAP_ComparatorConfigure(COMP_BASE,0,    //Comp0
                  COMP_TRIG_NONE                //  have no trigger to the ADC
                | COMP_ASRCP_PIN0                //  to use the dedicated Comp+ pin as the reference voltage
                | COMP_OUTPUT_NORMAL);          // enable a non-inverted output from the comparator to device pin
        MAP_ComparatorConfigure(COMP_BASE,1,    //Comp1
                  COMP_TRIG_NONE                //  have no trigger to the ADC
                | COMP_ASRCP_PIN0                //  to use the dedicated Comp+ pin as the reference voltage
                | COMP_OUTPUT_NORMAL);          // enable a non-inverted output from the comparator to device pin
        MAP_ComparatorConfigure(COMP_BASE,2,    //Comp2
                  COMP_TRIG_NONE                //  have no trigger to the ADC
                | COMP_ASRCP_PIN0                //  to use the dedicated Comp+ pin as the reference voltage
                | COMP_OUTPUT_NORMAL);          // enable a non-inverted output from the comparator to device pin

    }
    Franz

  • Hello Franz

    The configuration does not make a Open Drain Output. It will keep it in Push Pull IO topology

    Regards
    Amit
  • Hi Amit,

    Your report (push pull) confirms our findings.     We tied the MCU's analog comparator output pin directly to the PWM Fault Input pin - and then measured & verified expected signal levels - minus any pull-up/down Rs and/or external components.

    A possible downside resulting from "push pull" exists - the inability to provide a, "wired or" connection - by directly joining - multiple, analog comparator outputs.

    Past quad, analog comparators (LM339 etc.) exploited this.     One suspects this "wired or" may have been (the incorrectly verifying) poster's intent.

    Push pull is faster - so again - trade-offs result & must be noted for design success.