• AVR Freaks

Hot!Resistive touch ADC problem

Author
DatagramSKT
Starting Member
  • Total Posts : 40
  • Reward points : 0
  • Joined: 2010/04/01 09:37:34
  • Location: Italy
  • Status: offline
2019/07/11 13:36:11 (permalink)
0

Resistive touch ADC problem

Hi all,
I’m trying to handle a resistive touch LCD using an Olimex development board based on PIC32MZ2048EFG144 (Harmony v. 2.0.5.2 - MPLAB v.5.20).
I followed the aria_touchadc_calibrate (pic32_mz_ef_sk_s1d_pictail_wqvga) example as reference.
 
My Harmony configuration settings are here attached.
 
Each time the display is touched the debugger stops at the breakpoint inside DRV_TOUCH_ADC_STATE_SET_VALUES case (drv_touch_adc.c), but the static variables tempX and tempY are almost always 0 therefore the display doesn’t react.
 
I tried to change the value of Sample Time Count nSAMC (in ADC Channel Setup), Interrupt Priority (in Timer Driver Instance), and Timer Period, but without success.
Sometimes I get tempX or tempY with values different than 0, but with both variables very rarely correctly assigned even though the debugger stops inside DRV_TOUCH_ADC_STATE_GET_X /Y, where the assignment is done.
I put the call to DRV_TOUCH_ADC_PositionDetect inside the timer instance handler:
 
void IntHandlerDrvTmrInstance0(void)
{
    DRV_TOUCH_ADC_PositionDetect();
    PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_3);
}
 
I tried even to call DRV_TOUCH_ADC_PositionDetect from the system task but the flow enters inside DRV_TOUCH_ADC_STATE_SET_VALUES case, continuously.
What am I doing wrong ? Any suggestion ?
Thank you in advance.
 
Raffaele

Attached Image(s)


#1

7 Replies Related Threads

    jtzeng
    Super Member
    • Total Posts : 467
    • Reward points : 0
    • Joined: 2003/11/07 12:42:20
    • Status: offline
    Re: Resistive touch ADC problem 2019/07/11 13:54:18 (permalink)
    0
    Harmony version 2.06 is a better place to start.
    And this thread may help:
    https://www.microchip.com/forums/m1069348.aspx
     
    The other issue is the ADC being used.  The driver is only setup for Class 3 ADC.
    The HMC also has issues with generating the correct code for Class 2.
    It can be done.  I got mine to work with class 2 but had to fix some configuration in my app.
     
    Also use google to search for more posts on this in the Harmony 2 forum.
     

    John Zigrang
    JTZ Engineering, Inc.
    #2
    karan123
    Super Member
    • Total Posts : 852
    • Reward points : 0
    • Joined: 2009/02/02 11:11:21
    • Location: 0
    • Status: offline
    Re: Resistive touch ADC problem 2019/07/11 17:42:15 (permalink)
    0
    I have used PIC32MZ2048EFM100 with LCC and RTP, Harmony V2_06.
    Demo
    adc_touch_calibrate is worked for me But I have used same analog channel as in Demo.
    post edited by karan123 - 2019/07/11 21:37:44
    #3
    DatagramSKT
    Starting Member
    • Total Posts : 40
    • Reward points : 0
    • Joined: 2010/04/01 09:37:34
    • Location: Italy
    • Status: offline
    Re: Resistive touch ADC problem 2019/07/12 09:01:17 (permalink)
    0
    Jtzeng & karan123, thank you for your prompt reply.
     
    I tried both ADC driver modes (interrupt and polled) without success. All other settings are exactly the same suggested by automata now, except for the choice of the timer. I choose TMR_ID_2 so that “Timer driver INDEX to use” is DRV_TMR_INDEX_1. But this shouldn't make any difference.
     
    If Interrupt ADC mode is set the following ISR's are automatically generated:
     
    in system_interrupt.c 
    /* If individual interrupts are not enabled, all data interrupts are handled in this ISR */
    void IntHandlerDrvAdcCommonData(void)
    {
       /* Clear ADC Interrupt Flag of INT_SOURCE_ADC_1*/
       PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_ADC_1);
    }
     
    in drv_touch_adc.c:
    void __ISR(_TIMER_2_VECTOR, ipl1AUTO) IntHandlerDrvTouchAdc(void)
    {
        PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_TIMER_2);
        DRV_TOUCH_ADC_PositionDetect();
    }
     
    Compiling the project the following error is generated:
     
    system_interrupt_a.S:64: undefined reference to `IntHandlerDrvAdc'
     
    This error disappears by replacing the name IntHandlerDrvAdcCommonData with IntHandlerDrvAdc, but the flow never pass through IntHandlerDrvTouchAdc anyway.
     
    If polled ADC mode is set both the following ISR’s are automatically generated:
     
    in system_interrupt.c:
    void IntHandlerDrvTmrInstance0(void)
    {
        PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_3);// why 3 ???
    }
     
    in drv_touch_adc.c:
    void __ISR(_TIMER_2_VECTOR, ipl1AUTO) IntHandlerDrvTouchAdc(void)
    {
        PLIB_INT_SourceFlagClear(INT_ID_0, INT_SOURCE_TIMER_2);
        DRV_TOUCH_ADC_PositionDetect();
    }
     
    and the compiling completes successfully, but the result is the same. The IntHandlerDrvTouchAdc call is never done.
     
    Thanks again for your help !
     
     
    Raffaele
     
    #4
    jtzeng
    Super Member
    • Total Posts : 467
    • Reward points : 0
    • Joined: 2003/11/07 12:42:20
    • Status: offline
    Re: Resistive touch ADC problem 2019/07/12 11:07:46 (permalink)
    0
    The ADC should be poled.
    The ADC_Touch_Drive will run the ADC conversion and setup.
    It also does the poling for conversion completion.
     
    What ADC channels are you using for the X+ and Y+.  Which ports I/O for X- and Y-.
    Only class 3 will configure correctly in Harmony 2.06.

    John Zigrang
    JTZ Engineering, Inc.
    #5
    jtzeng
    Super Member
    • Total Posts : 467
    • Reward points : 0
    • Joined: 2003/11/07 12:42:20
    • Status: offline
    Re: Resistive touch ADC problem 2019/07/12 11:16:02 (permalink)
    0
    Here is the thread where we figured out how to make class 2 ADC CH work:
    https://www.microchip.com...1078703.aspx?tree=true

    John Zigrang
    JTZ Engineering, Inc.
    #6
    DatagramSKT
    Starting Member
    • Total Posts : 40
    • Reward points : 0
    • Joined: 2010/04/01 09:37:34
    • Location: Italy
    • Status: offline
    Re: Resistive touch ADC problem 2019/07/13 04:48:01 (permalink)
    0
    Hi Jtzeng,
    I'm using AN15 and AN16 channels...both Class 3. This is my pin's configuration:
     
    RE6 (AN16) -> BSP_ADC_TOUCH_XPLUS - GPIO - digital in
    RE7 (AN15) -> BSP_ADC_TOUCH_YPLUS - GPIO - digital in
    RE3 (...)  -> BSP_ADC_TOUCH_XMINUS - GPIO - digital in
    RE4 (AN18) -> BSP_ADC_TOUCH_YMINUS - GPIO - digital in
     
    RB12 (AN7) -> available
     
    Maybe the problem could be RE3 pin ?
     
    Raffaele
    #7
    karan123
    Super Member
    • Total Posts : 852
    • Reward points : 0
    • Joined: 2009/02/02 11:11:21
    • Location: 0
    • Status: offline
    Re: Resistive touch ADC problem 2019/07/13 05:45:33 (permalink)
    0
    DatagramSKT
    Hi Jtzeng,I'm using AN15 and AN16 channels...both Class 3. This is my pin's configuration: RE6 (AN16) -> BSP_ADC_TOUCH_XPLUS - GPIO - digital inRE7 (AN15) -> BSP_ADC_TOUCH_YPLUS - GPIO - digital inRE3 (...)  -> BSP_ADC_TOUCH_XMINUS - GPIO - digital inRE4 (AN18) -> BSP_ADC_TOUCH_YMINUS - GPIO - digital in RB12 (AN7) -> available Maybe the problem could be RE3 pin ? Raffaele


    Hi

    You don't need 4 ADC Channels.
    You have to use only 2 Analog and 2 Digital Pins for 4 wire Resistive Touch Panel.

    Hope this helps..
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5