Interrupt Menu System Example and Help Needed


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Bellevue
    Posts
    125


    Did you find this post helpful? Yes | No

    Default

    With the 18F2525, there is an INT setting for external interrupts on RB0-2. From the sheet:
    -----------------------------------------------
    9.6 INTn Pin Interrupts
    External interrupts on the RB0/INT0, RB1/INT1 and
    RB2/INT2 pins are edge-triggered. If the corresponding
    INTEDGx bit in the INTCON2 register is set (= 1), the
    interrupt is triggered by a rising edge; if the bit is clear,
    the trigger is on the falling edge. When a valid edge
    appears on the RBx/INTx pin, the corresponding flag
    bit, INTxF, is set. This interrupt can be disabled by
    clearing the corresponding enable bit, INTxE. Flag bit,
    INTxF, must be cleared in software in the Interrupt
    Service Routine before re-enabling the interrupt.
    All external interrupts (INT0, INT1 and INT2) can wakeup
    the processor from Idle or Sleep modes if bit INTxE
    was set prior to going into those modes. If the Global
    Interrupt Enable bit, GIE, is set, the processor will
    branch to the interrupt vector following wake-up.
    Interrupt priority for INT1 and INT2 is determined by the
    value contained in the interrupt priority bits, INT1IP
    (INTCON3<6>) and INT2IP (INTCON3<7>). There is
    no priority bit associated with INT0. It is always a high
    priority interrupt source.

    ----------------------------------------------------
    I have set (I think) the appropriate bits for B0 and B1 to be interrupts. How can I tell the difference in an interrupt routine tho?? Since I am not watching for B1 to go high.... ????

    Tom

  2. #2
    Join Date
    Feb 2003
    Location
    Delaware
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Ok more on the pot.

    Tom,

    The value of the pot doesn't really matter as long as its over say 5k. You see you are going to set up a voltage divider across Vcc and ground with the wiper going to the A/D pin. Then I simply read the value of the A/D (0 -1023) and I divide it to give me the number of selections I need. Here is an example. Note the tmr1cnt variable. TMR1 is free running with a 1mS period and tmr1cnt is a variable that is incremented every 1mS. This is compared to mud(menu update) to provide the timing to smoothly update the display. The other timing is provided by the variable "I". It is updated every 1mS if a button is pressed. It is cleared if the button is released. This variable is compared to MBP(menu button press) to debounce the button and ensure that it was held in for a bit.

    read_pot:
    adcin 3, adval3
    y = adval3 / 204
    return

    SETUP_MENU:
    if tmr1cnt > mud then
    tmr1cnt = 0
    gosub read_pot
    x = x + 1
    endif
    select case y
    case 0
    lcdout $FE,$C0,"->Reset Counters"
    case 1
    lcdout $FE,$C0,"->Set Rej. Dwell"
    case 2
    lcdout $FE,$C0,"->Set Threshold "
    case 3
    lcdout $FE,$C0,"->Prog. Scanner "
    case 4,5
    lcdout $FE,$C0,"->Exit Setup "
    end select
    if i > MBP then
    select case y
    case 0
    tmr1cnt = 0
    i = 0
    gosub reset_counters
    case 1
    tmr1cnt = 0
    i = 0
    gosub set_dwell
    case 2
    tmr1cnt = 0
    i = 0
    gosub set_thrsh
    case 3
    tmr1cnt = 0
    i = 0
    gosub prog_scan
    case 4,5
    @ BSF 0x06,1 ;SCANNER Off
    gosub SETUP_LCD
    goto main
    end select
    endif
    goto SETUP_MENU


    Hope this helps

    Joe

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