My suggestion, use the interrupt on PORTB change. Have a look to the datasheet.
Once you jump to the interrupt routine, check the state of your push-buttons and do the according stuff or set some specific flags and do your stuff in the MAINLOOP.
 
 
		My suggestion, use the interrupt on PORTB change. Have a look to the datasheet.
Once you jump to the interrupt routine, check the state of your push-buttons and do the according stuff or set some specific flags and do your stuff in the MAINLOOP.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
 
 
		OK - Once I am in the interrupt routine I need it to WAIT for a few seconds for the user to either click the BO again (in which case I'd do one thing), or click the B1, in which case I'd do something different.
My problem is I can't find a way to WAIT... Is it some sort of loop?
while RB0 <> pressed then do (do main routine stuff - read from port/convert)
* time out after 5 seconds and return
If RB1 is pressed then do (something)
if RB0 is pressed then do (something else)
wend
??
 
 
		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
 Ok more on the pot.
 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
Bookmarks