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.

Problem analog comparator interrupt

Other Parts Discussed in Thread: TM4C123GH6PMI have problem on how to interrupt analog comparator..... can teach me?
  • Hi Dorene,

    Provide relevant details. See, the link below at my signature "Information to provide when asking for help". Also, post your code here.

    -kel

  • Hello Dorene,

    Can you be more precise in terms of which TM4C device, which reference source for the comparator, type of interrupt?

    Regards

    Amit

  • Amit Ashara said:
    Can you be more precise ... 

    Of course - "PC Always" rules - but conferring any, "precision" to opening/requesting post is a major, "reach."

  • Hi amit, Im using tm4c123gh6pm.....i tried to interrupt comp 0....to show the pariority when rising edge.... but i failed.... can u teach me?
  • Hi kel, Here is my codes: #include #include #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/pin_map.h" #include "driverlib/sysctl.h" #include "driverlib/comp.h" #include "inc/tm4c123gh6pm.h" #include "driverlib/interrupt.h" #include "grlib/grlib.h" #include "grlib/widget.h" #include "grlib/canvas.h" #include "grlib/pushbutton.h" #include "Kentec320x240x16_ssd2119_8bit.h" #include "touch.h" extern tCanvasWidget g_sBackground; extern tPushButtonWidget g_sPushBtn; tContext g_sContext; tRectangle sRect; void OnButtonPress(tWidget *pWidget); void ClrScreen(void); void IntDefaultHandler(void); Canvas(g_sBackground, WIDGET_ROOT, 0, &g_sPushBtn, &g_sKentec320x240x16_SSD2119, 0, 0, 320, 240, CANVAS_STYLE_FILL, ClrDeepPink, 0, 0, 0, 0, 0, 0); RectangularButton(g_sPushBtn, &g_sBackground, 0, 0, &g_sKentec320x240x16_SSD2119, 100, 190, 200, 40, (PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT | PB_STYLE_FILL), ClrLawnGreen, ClrWhite, ClrRed, ClrBlue, g_psFontCmss22b, "TOUCH Here !", 0, 0, 0, 0, OnButtonPress); void ClrScreen() { sRect.i16XMin = 120; sRect.i16YMin = 100; sRect.i16XMax = GrContextDpyWidthGet(&g_sContext) - 140; sRect.i16YMax = 140; GrContextForegroundSet(&g_sContext, ClrDeepPink); GrRectFill(&g_sContext, &sRect); GrFlush(&g_sContext); } int Count; char display[ ]; void OnButtonPress(tWidget *pWidget) { if(Count) { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x08); SysCtlDelay(SysCtlClockGet()/10/3); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x00); Count=0; } else { } } void IntDefaultHandler() { GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0x04); SysCtlDelay(SysCtlClockGet()/10/3); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0x00); Count++; SysCtlDelay(SysCtlClockGet()/10/3); ClrScreen(); } int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00); SysCtlPeripheralEnable(SYSCTL_PERIPH_COMP0); ComparatorConfigure(COMP_BASE, 0, COMP_TRIG_NONE | COMP_INT_RISE | COMP_ASRCP_REF | COMP_OUTPUT_INVERT); ComparatorRefSet(COMP_BASE, COMP_REF_0V); ComparatorIntEnable(COMP_BASE,0); Kentec320x240x16_SSD2119Init(); TouchScreenInit(); TouchScreenCallbackSet(WidgetPointerMessage); WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground); WidgetPaint(WIDGET_ROOT); while(1) { GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119); GrContextForegroundSet(&g_sContext, ClrWhite); GrRectDraw(&g_sContext, &sRect); GrContextFontSet(&g_sContext, &g_sFontCm24); GrStringDrawCentered(&g_sContext, "COUNTER ", -1, GrContextDpyWidthGet(&g_sContext) / 2, 11, 0); GrContextFontSet(&g_sContext, &g_sFontCm40); GrStringDrawCentered(&g_sContext, display[ ], -1, 150, 120, 0); WidgetMessageQueueProcess(); } }
  • Hi Dorene,

         If you want to insert code at your E2E post, there is a "Insert code using Syntaxhighlighter" tool. See, below. You, can also preview your reply by going to the "Preview tab". This way you know everything is what you expect it to be.

    -kel

  • Hello Dorene,

    Indeed we can help you and to ensure that you learn, I will keep the parameters for the functions mentioned below open, so that you can also research and learn along side

    I went through the code and here is what I have the changes that need to be done

    1. The Comparator Pins have not been configured to allow the external input to get connected to the Comparator Module. For doing that you need to cal the GPIO API's before you configure the comparator module.

    GPIOPinConfigure(GPIO Comparator Pin Configuration as done in pin_map.h);

    GPIOPinTypeComparator(GPIO Base Address, GPIO Pin Number)

    2. The Interrupt for the Compartor needs to be enabled in the NVIC module before the call for Kentec320x240x16_SSD2119Init function

    IntEnable(The Interrupt define as given in hw_ints.h);

    IntMasterEnable();

    3. Do not use IntDefaulthandler as it may create issue when multiple interrupt handlers are needed later. Instead give it a name other than IntDefaultHandler and then put the same name in the startup_ccs.c file at the correct interrupt position in the Interrupt Table

    4. Which function is the Interrupt Handler for the Analog Compartor?

    Regards

    Amit

  • Dear Amit, I want my interrupt can be count the edge rise and will show the counting on the display LCD ....i tried but failed... isnt becoz of i didnt configure correctly? Dorene
  • Hello Dorene,

    Do you mean, that you want to count the edge rise on a signal :may be connected to a switch that the user presses or some signal coming from external device? Please clarify

    Did you make the changes to your code as I had suggested?

    Regards

    Amit

  • hi Kel,

    thx~Actually i not quite understand the link that you share....

    TM4C123 NMI unlock

    Could you kindly explain?

    Dorene

  • Hello Dorene

    So you would take the output of the comparator? The post title was more related to the interrupt which is confusing.

    Do make things clearer with the new information

    1. You have a signal which is the input to the comparator

    2. The output of the comparator is taken out of the TM4C device to be used elsewhere?

    Regards

    Amit

  • Hi Amit,

    cant...

    1.yes, a input signal to PC7.

    2.no, i need to show the counting the edge rise on the LCD.

    Regards,

    Dorene

  • Hello Dorene

    Thanks for the clarification. I again went through the new code and you have missed enabling the module

     SysCtlPeripheralEnable(SYSCTL_PERIPH_COMP0);

    It should have given a bus fault.

    Regards

    Amit

  • Hello Dorene

    Got some time out to make a simple Analog Comparator Code that you can run on a TM4C123 LaunchPad. Every time you connect the PC6 pin to 3.3V the Blue LED will blink,

    http://e2e.ti.com/cfs-file.ashx/__key/communityserver-discussions-components-files/908/2577.TM4C123_5F00_ACMP.7z

    Regards

    Amit