Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4748

How to create 6 buttons?

$
0
0
Hello everyone!
I'm trying to develop a basic queuing system, using 2 digit 7 segment. Currently I have 3 buttons to trigger a bell and increment the value display. So far the main functionality are working...but at the moment buttons are on PORTA. The problem I'm facing is when buttons are pressed long enough it continues to increment in which I do not want. My solution is to use DT's interrupt library, using external interrupt (on Pic18F4550).
For testing I use the following codes...
Code:

asm
    __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
    __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    ;__CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L 
    __CONFIG    _CONFIG2H, _WDT_OFF_2H
    __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
    __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm
Define OSC 20


INCLUDE "DT_INTS-18.bas"    ; Base Interrupt System
INCLUDE "ReEnterPBP-18.bas"    ; Include if using PBP interrupts
TRISD = %00000000
PORTD = %00000000
Led1 Var POrtD.5
ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
        INT_Handler    INT0_INT,  _ToggleLED1,  PBP,  yes 
        INT_Handler    INT1_INT,  _ToggleLED1,  PBP,  yes 
        INT_Handler    INT2_INT,  _ToggleLED1,  PBP,  yes
        endm
    INT_CREATE              ; Creates the interrupt processor
ENDASM

@  INT_ENABLE  INT0_INT    ; enable external (INT) interrupts@  INT_ENABLE  INT1_INT    ; enable external (INT) interrupts
@  INT_ENABLE  INT1_INT
@  INT_ENABLE  INT2_INT


Main:
  PAUSE 100
GOTO Main

'---[INT - interrupt handler]---------------------------------------------------
ToggleLED1:
    TOGGLE LED1
@ INT_RETURN

Works perfectly for my project...now my question is, I know PORTB has 3 external interrupt. Is there a way I can make the same functionality for 6 buttons? I've read some about interrupt on ANY pins but not really sure how to implement it. Hope anyone can give me an idea/help ..appreciate it very much.
Attachment 6760


Thanks in advance,
tacbanon
Attached Images
 

Viewing all articles
Browse latest Browse all 4748

Trending Articles