Controlling an 240x128 LCD Touchpanel Display


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Vincent's Avatar
    Vincent Guest

    Default Controlling an 240x128 LCD Touchpanel Display

    Hello everybody

    First to say i'm new here.

    I've got a very complex problem,
    I'm trying to controll a LCD Display with touchpanel via interrupts and RS232 interface.
    I'm using an PIC18F452 Controller
    and this Display: http://www.electronicassembly.de/eng...k/kit2407e.pdf
    www.lcd-module.de/deu/pdf/grafik/kit240-7.pdf

    All the comunication with the controler and the Display is working fine.
    Also the comands from the Display are recived via RS232 interrupt.
    The Problem now is: I need the controller to count seconds.
    I tryed to do this via Timer1 interrupt but this is not working!
    The CODE I use looks like this:
    '-----Interrupt--settings---------------------------------------------------
    PIE1.5 = 1 'Interrupt Enable "Empfang
    PIR1.5 = 0 'Interrupt Flag bit Empfang
    PIR1 = $00 'alle anstehenden Interrupts löschen
    PIR2 = $00 '

    INTCON = %11100000 'GIE,PEIE , testing bit5 = 1
    INTCON2 = %00000000 'Interrupt Kontrollregister 2

    Timer1-------------------------------------------------------------------------
    T1CON = %10001001 '7=16Bit,5-4=Prescaler,0=Timer ON
    PIE1.0=1 'testing 'Interrupt enable für Timer1
    TMR1H =0 'Timer Hight Byte
    TMR1L =0 'Timer Low Byte
    IPR1.0=1 'Interrupt Priorität High

    disable '------------ INTERRUPT -Handler------------------------
    inter:


    If ( PIR1.0 == 1) Then ' Timer1 overflow
    'toggle led 'LED zustand wechseln

    zeiteinheit = zeiteinheit + 1 'Variable "Zeiteinheit" hochzählen
    if (zeiteinheit >= 15) Then
    zeiteinheit = 0
    sek = sek +1 'Variable "sek" hochzählen

    if sek>999 Then
    sek = 0 'Variable "sek" auf 0 setzen
    endif

    endif

    PIR1.0 = 0 'Timer1 überlaufflag auf 0 setzen
    TMR1H = $00 'testing 'Zählregister mit dem Wert vorbelegen
    TMR1L = $00 'testing 'Zählregister mit dem Wert 0 vorbelegen

    endif



    if ( PIR1.5 == 1 ) then 'Zeichen über RS232 Schnittstelle

    empf = RCREG 'Empfangsregister in empf kopieren

    select case empf 'Auswahl anhand des empfangenen Zeichen treffen
    CASE 22, 8, 12, 61
    anzeige = 0
    GOSUB main_menue_int
    case 71, 40, 50
    anzeige = 0
    endpunkt = "D"
    gosub menue_sensoren
    case 72
    gosub menue_Messablauf
    case 73, 33
    gosub menue_einstellungen
    case 74
    gosub menue_credits
    CASE 20
    anzeige = "D"
    druck_aktiv_flag = 1
    temp_aktiv_flag = 0
    querbeschl_aktiv_flag = 0 laengsbeschl_aktiv_flag = 0
    hserout [27,66, 82, 5, 2, 120, 240, 128, 0, 254, 1]
    pause mx
    GOSUB menue_drucksensor
    CASE 21
    anzeige = "T"

    druck_aktiv_flag = 0
    temp_aktiv_flag = 1
    querbeschl_aktiv_flag = 0
    laengsbeschl_aktiv_flag = 0

    hserout [27,66, 82, 5, 2, 120, 240, 128, 0, 254, 1]
    pause mx
    GOSUB menue_temperatur
    case 23
    anzeige = "G"
    'beschleunigung_flag = 0
    hserout [27,66, 82, 5, 2, 120, 240, 128, 0, 254, 1]
    pause mx
    gosub menue_geschw
    case 25
    anzeige = "Q"
    druck_aktiv_flag=0 temp_aktiv_flag = 0
    querbeschl_aktiv_flag = 1
    laengsbeschl_aktiv_flag = 0

    hserout [27,66, 79, 3, 2]
    pause mx
    hserout [60, 10, 1, 0, 254, 1]
    pause mx

    hserout [27,66, 85, 4, 2]
    pause mx
    hserout [61, 10, 125, 0, 254, 1]
    pause mx

    gosub menue_quer
    case 26
    anzeige = "L"

    druck_aktiv_flag = 0
    temp_aktiv_flag = 0
    querbeschl_aktiv_flag = 0
    laengsbeschl_aktiv_flag = 1

    hserout [27,66, 82, 1, 120]
    pause mx
    hserout [120, 240, 128, 0, 254, 1]
    pause mx

    hserout [27,66, 76, 2, 119]
    pause mx
    hserout [120, 0, 128,254,1]
    pause mx
    gosub menue_laengs

    Case 24
    anzeige = "q"
    beschleunigung_flag = 0
    Gosub menue_besch
    CASE 7
    anzeige = "Z"
    gosub menue_zeit
    CASE 28
    anzeige = 0
    scroll_flag = 1
    'GOSUB menue_offset
    'gosub scrollmenue_offset
    gosub menue_offset
    CASE 11
    anzeige = 0
    scroll_flag = 0
    GOSUB menue_Grundeinst
    gosub scrollmenue_einstellungen

    CASE 62

    GOSUB analog_offset_1

    HSerout [27,82,76,150,45,240,65] 'bereich löschen
    pause mx
    HSEROUT [27,70,3,1,1] 'Font 3 verwenden
    pause mx '
    Hserout [27,90,76,150,50,"Offset = ",#wert_offset1,0]
    pause mx



    case 63
    gosub analog_offset_2

    HSerout [27,82,76,150,65,240,85] 'bereich löschen
    pause mx
    HSEROUT [27,70,3,1,1] 'Font 3 verwenden
    pause mx
    Hserout [27,90,76,150,72,"Offset = ",#wert_offset2,0]
    pause mx

    case 64
    gosub analog_offset_3

    HSerout [27,82,76,150,85,240,105] 'bereich löschen
    pause mx
    HSEROUT [27,70,3,1,1] 'Font 3 verwenden
    pause mx
    Hserout [27,90,76,150,95,"Offset = ",#wert_offset3,0]
    pause mx


    case 30
    hserout [27,78,80]
    case 31
    hserout [27,78,78]
    case 32
    anzeige = "a"

    case 1

    hserout [27,68,82]
    GOSUB main_menue_int

    anzeige = 0
    case 2

    Toggle anzeige_einheit
    gosub anzeige_einheit_aendern
    gosub scrollmenue_einstellungen

    anzeige = 0
    case 3

    toggle ton
    gosub tonaendern
    gosub scrollmenue_einstellungen

    anzeige = 0
    case 4

    toggle beschl_switch
    gosub beschl_einheit_aendern 'Ändern der Anzeigeeinheit für Beschleunigung
    gosub scrollmenue_einstellungen

    anzeige = 0

    case else
    gosub main_menue_int 'gehe zurück ins Hauptmenü
    end select

    ENDIF


    GOTO int_ende
    '--------------------------------------------------------------------------

    if i now enable the Timer1 interrupt every time a Timer1 interrupt is aktive also the RS232 ELSE CASE will be carried out
    if i disable the Timer1 interrupt put keep the Timer1 runnig ervery time a RS232 interrupt is aktive also the Timer1 interrupt serviceroutine will be carried out.

    If there is anybody here who can help me on this problem i would be very glad
    and thankeful

    by NVM

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i saw 2 things
    1. You can't use Gosub in a interrupt handler
    2. I don't see that you re-enable the interrupts

    And it should be only a part of your program 'cause i don't see any ON Interrupt goto statement.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Vincent's Avatar
    Vincent Guest


    Did you find this post helpful? Yes | No

    Smile One of Two

    Thanks mister_e!

    I will try to reprogram the interrupthandler without using GOSUB.

    The on interrupt goto statement is written in a GOSUB init: funktion which is called befor the main: loop
    '--------------------------------------------------------------------------
    inter_default:
    on interrupt goto inter
    return
    '--------------------------------------------------------------------------

    The reenabeling of interrupt is done in this two funktions:
    '--------------------------------------------------------------------------
    int_ende: 'Interrupt Ende

    z1_tmp=10
    z2_tmp=10
    z3_tmp=10
    z4_tmp=10

    resume main_ende
    enable

    '--------------------------------------------------------------------------
    main_ende:
    pause 10
    goto main

  4. #4
    Vincent's Avatar
    Vincent Guest


    Did you find this post helpful? Yes | No

    Unhappy reprograming done

    No my interrupthandler is working without any GOSUB routine.
    But the problem with having a variable counted up via a timer1 interrupt is still there.
    ???

    by NVM

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    > You can't use Gosub in a interrupt handler

    Not true.

    You just got to watch how many Interrupts & Gosubs you've got pushed on the stack and not exceed the maximum allowed. The sum total in most cases must not exceed FOUR.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Smile

    mmm interesting... it's different from what i already heard somewhere. I should test it one day.

    Usually my interrupt handler are just short and mostely set Flag and variable wich are tested in the main program, then it react depending of them.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. LCD Display
    By lambert in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 16th January 2010, 22:18
  2. LCD display not working properly
    By dilpkan in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 2nd February 2008, 07:43
  3. Replies: 14
    Last Post: - 26th September 2007, 05:41
  4. LCD Display not working - PIC heating...
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 24th September 2006, 07:35
  5. A/D display result on LCD
    By winsthon in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 10th January 2004, 10:09

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts