• AVR Freaks

gRaphics Library & Touch screen

Author
dmccric
Senior Member
  • Total Posts : 153
  • Reward points : 0
  • Joined: 2006/05/30 08:13:15
  • Location: Bradford, England
  • Status: offline
2009/03/31 08:40:59 (permalink)
0

gRaphics Library & Touch screen

I am using the Microchip Graphics Library V1.60 with an SSD1906 controller and an Hitachi 3.5" TFT Display and I have connected some temperature sensors to the analog inputs. Every 500ms I disable the touch screen (TMR3, Ext. Int. 1 & ADC Interrupt) and enable the ADC for my temperature sensor. I get the correct temperature and then set the ADC registers back to how they were and re-enable the interrupts but the touchscreen does not work after the first sample.

My sensor keeps displaying the changing temperature, the interrupts are still running for the touch screen as I set an led to flash when the touch screen is pressed (Ext. Int. 1) but it still doesn't work.

Any help is appreciated as i'm running out of hair.

Cheers

DM
#1

11 Replies Related Threads

    jmag99
    Super Member
    • Total Posts : 486
    • Reward points : 0
    • Joined: 2007/09/21 08:04:33
    • Location: RI, United States
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/03/31 08:43:05 (permalink)
    0
    Why not just add the temp sensor into the state machine?  That way you don't have to disable it.

    When you say you disable it, did you disable both the timer and adc?
    #2
    dmccric
    Senior Member
    • Total Posts : 153
    • Reward points : 0
    • Joined: 2006/05/30 08:13:15
    • Location: Bradford, England
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/03/31 08:57:04 (permalink)
    0
    I did but it still did not work, I tried it in the state machine which checks the temperature more often and as a separate function which checks it only every 500ms. I use the TouchInit() function to setup the touch screen parameters once I have finished reading the temperature but still no touch action.
    #3
    zardoz1
    Super Member
    • Total Posts : 1852
    • Reward points : 0
    • Joined: 2005/07/09 08:03:28
    • Location: 's-Hertogenbosch, The Netherlands
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/03/31 10:34:34 (permalink)
    0
    ORIGINAL: dmccric

    I am using the Microchip Graphics Library V1.60 with an SSD1906 controller and an Hitachi 3.5" TFT Display and I have connected some temperature sensors to the analog inputs. Every 500ms I disable the touch screen (TMR3, Ext. Int. 1 & ADC Interrupt) and enable the ADC for my temperature sensor. I get the correct temperature and then set the ADC registers back to how they were and re-enable the interrupts but the touchscreen does not work after the first sample.

    My sensor keeps displaying the changing temperature, the interrupts are still running for the touch screen as I set an led to flash when the touch screen is pressed (Ext. Int. 1) but it still doesn't work.

    Any help is appreciated as i'm running out of hair.

    Cheers

    DM

     
    I did almost the same and for me it works. The only thing I did to disable the touchscreen is stop timer3 and stop the ADC and the reinitialize for the ADC channels I want to read.
     
    After that I execute the touchscreen ADC initialization code as present in the LIB. I also increased the touchscreen frequency (shorter timer period). I seem to remember before doing this I had the same problem you are mentioning. I use period 100us and prescaler 2. so a period of 200us.


    AVIX
    the PIC32 & dsPIC/PIC24 RTOS with:
    - Zero Latency Interrupts
    - The best performance!
    - Integrated Power Management
    Download here: http://www.avix-rt.com/
    #4
    dmccric
    Senior Member
    • Total Posts : 153
    • Reward points : 0
    • Joined: 2006/05/30 08:13:15
    • Location: Bradford, England
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/04/02 07:29:37 (permalink)
    0
    I have debugged the program and find that all the interrupts are working correctly, the ADC, EXT. INT. 1& Timer 3 Interrupts,
    This is how the code looks now:

    // Disable Interrupts
        T3CONbits.TON = FALSE;                                            // Disable Timer 3
        IEC1bits.AD1IE = FALSE;                                            // Disable ADC Interrupt
        IEC0bits.INT1IE = FALSE;                                           // Disable External Interrupt 1 - XR bit for TS

    // Configure ADC
        AD1CON1 = 0;                                                        // Disable the ADC
        AD1CON1 = 0x00E0;                                                // Manual conversion sequence control
        AD1CON1bits.ADON = TRUE;                                     // Take the sample

    // Read the ADC
        AD1CHSbits.CH0SA = 12;                                            // Select AN12, using MUXA
        AD1CON1bits.SAMP = TRUE;                                        // Start sampling
        while(!AD1CON1bits.DONE);                                         // Wait for conversion to finish
        TEMP2 = ADC1BUF0;                                                  // Store sampled temp value
        AD1CON1 = 0;                                                          // Disable the ADC

    // Put the touch screen states back
        TouchInit();                                                            // Setup the touchscreen again

    // Re-enable the interrupts
        IEC0bits.INT1IE = TRUE;                                            // Enable External Interrupt 1 - XR bit for TS
        IEC0bits.T3IE = 1;                                                   // Enable Timer Interrupt
        IEC1bits.AD1IE = TRUE;                                            // Enable ADC Interrupt

    My temperature reading is working fine like I said but no button presses at all even though
    the interrupts are working.

    #5
    zardoz1
    Super Member
    • Total Posts : 1852
    • Reward points : 0
    • Joined: 2005/07/09 08:03:28
    • Location: 's-Hertogenbosch, The Netherlands
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/04/02 08:23:41 (permalink)
    0
    what type of controller are you using?


    AVIX
    the PIC32 & dsPIC/PIC24 RTOS with:
    - Zero Latency Interrupts
    - The best performance!
    - Integrated Power Management
    Download here: http://www.avix-rt.com/
    #6
    dmccric
    Senior Member
    • Total Posts : 153
    • Reward points : 0
    • Joined: 2006/05/30 08:13:15
    • Location: Bradford, England
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/04/02 08:37:15 (permalink)
    0
    Im using the Soloman Systech SSD1906 with an Hitachi TX09D40 Display with touchscreen.
    #7
    zardoz1
    Super Member
    • Total Posts : 1852
    • Reward points : 0
    • Joined: 2005/07/09 08:03:28
    • Location: 's-Hertogenbosch, The Netherlands
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/04/02 10:07:57 (permalink)
    0
    ORIGINAL: dmccric

    Im using the Soloman Systech SSD1906 with an Hitachi TX09D40 Display with touchscreen.

     
    Actually I meant what PIC? wink


    AVIX
    the PIC32 & dsPIC/PIC24 RTOS with:
    - Zero Latency Interrupts
    - The best performance!
    - Integrated Power Management
    Download here: http://www.avix-rt.com/
    #8
    dmccric
    Senior Member
    • Total Posts : 153
    • Reward points : 0
    • Joined: 2006/05/30 08:13:15
    • Location: Bradford, England
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/04/03 01:37:12 (permalink)
    0
    I'm using the PIC32MX360F512L 100-pin.

    I have put the code into the touch screens state machine inside 'Touchscreena.c.' which will read the temperature when I set the timer off
    but this gives me an incorrect value even though the parameters are the same.

    The only difference that I can see is the channel and that I used manual conversion and the touchscreen uses automatic conversion.

    #9
    zardoz1
    Super Member
    • Total Posts : 1852
    • Reward points : 0
    • Joined: 2005/07/09 08:03:28
    • Location: 's-Hertogenbosch, The Netherlands
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/04/03 01:58:35 (permalink)
    5 (1)
    Ok, you are using a PIC32 which I was hoping for.
     
    There is one thing you have to keep in mind when using PIC32. Changing the value of bits in SFR's are subject to the Read-Modify-Write problem. This problem can occur when you are using concurrency which is either interrupts, an RTOS or both. I don't know whether you are using an RTOS but you are using interrupts.
     
    When setting a bit from an interrupt handler like:
     
    IEC0bits.INT1IE = 1
     
    this results in reading the IEC0 register, modifying the bit and writing the result back to IEC0. If this is done while another part of your code is also manipulating the same register, when the ISR returns, the action taken from the ISR is destroyed by the original interrupted code finishing its Read-Modify-Write.
     
    To prevent this, PIC32 contains a whole new class of registers, the ...SET, ...CLR and ...INV registers. These are intended to be used for atomic bit manipulation not subject to the Read-Modify-Write problem.
     
    So beside the IEC0 register there is also IEC0SET, IEC0CLR and IEC0INV. By writing a bitpattern to the desired register, the bits corresponding to a 1 in the value you write is either set, cleared or inverted. Important is this is done atomic, the action can not be interrupted and is guaranteed to deliver the desired result.
     
    So for instance:
     
    IEC0SET = 0x0000000F;
     
    Will set bit 0..3 in IEC0 without the risk it is interrupted.
     
    I am not sure whether you are hurt by this problem since it all depends on timing of your system and it might well be the case everything is going OK (as far as bit manipulation is concerned that is). However do change your code to use those special registers and with PIC32 be very carefull using the method that does work for PIC24/33. Actuall it is good practice just not to use these anymore.
     
     
    I also have changed bit manipulation in the Graphic library since here too a lot of old-fashioned bit manipulation on SFR's is going on and in a interrupt/RTOS environment these are just no good for PIC32.
     
     
    The PIC32 libraries contain macros that can help you with this. These macros start with a 'm'. Please look in the peripheral doc to find them.


    AVIX
    the PIC32 & dsPIC/PIC24 RTOS with:
    - Zero Latency Interrupts
    - The best performance!
    - Integrated Power Management
    Download here: http://www.avix-rt.com/
    #10
    dmccric
    Senior Member
    • Total Posts : 153
    • Reward points : 0
    • Joined: 2006/05/30 08:13:15
    • Location: Bradford, England
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/04/03 04:30:03 (permalink)
    0
    Thanks for that, it has helped a bit, I can now read the temperature and touch the screen but the screen touch is erratic.
    Only the check boxes work correctly, I am using buttons and radio buttons on my screen, in order to press the radio button I
    have to first press the check box, I don't know why but it only let me press an object if I press the check box first.

    Very strange, this should of been a simple case of switching channels but I have been on this for ages.
    #11
    dmccric
    Senior Member
    • Total Posts : 153
    • Reward points : 0
    • Joined: 2006/05/30 08:13:15
    • Location: Bradford, England
    • Status: offline
    RE: gRaphics Library & Touch screen 2009/04/03 05:32:04 (permalink)
    0
    I have managed to get it working now by putting my reading of the temp. sensor back into the state machine
    of the touch screen and then by using the SET & CLR operands to configure the sensor & touch screen when
    needed.

    Thanks for the help
    #12
    Jump to:
    © 2019 APG vNext Commercial Version 4.5