I am building a seminar timer and i need some design advice...
Firstly my seminar timer needs to be able to set the time duration reqd ie say 3:40 meaning 3 min and 40 sec..and then this time must be wirelessly transmitted to a slave clock..
To start off with the very basics, i have decided on 6 push buttons (1) min (2) sec (3)Reset (4)Start (5)Stop (6)Trasmit and i wanted to use a interrupt based approached to decide which button has been pressed, and then go to the subroutine, problem was i used the RBIE intrrupt, RB port change on RB4-7 only to realise that i can only cater this interrupt to 4 of my push buttons while i have 6 of it..i initially plan to have a interrupt service routine to cater to each of the push buttons but reading up on interrupts, i found out that isr starts at 0x04.. so does this mean that i can only have one isr and not many isr for diff cases?
i will put down what i have written as a skelthon, can give me advise me or correct if i am heading in the wrong dirn..Thanks a millon.
This is how i intend to approach my problem, being a first time programmer to pic, i will welcome all useful comments or advice from all of u..Thanks once again.
Firstly my seminar timer needs to be able to set the time duration reqd ie say 3:40 meaning 3 min and 40 sec..and then this time must be wirelessly transmitted to a slave clock..
To start off with the very basics, i have decided on 6 push buttons (1) min (2) sec (3)Reset (4)Start (5)Stop (6)Trasmit and i wanted to use a interrupt based approached to decide which button has been pressed, and then go to the subroutine, problem was i used the RBIE intrrupt, RB port change on RB4-7 only to realise that i can only cater this interrupt to 4 of my push buttons while i have 6 of it..i initially plan to have a interrupt service routine to cater to each of the push buttons but reading up on interrupts, i found out that isr starts at 0x04.. so does this mean that i can only have one isr and not many isr for diff cases?
i will put down what i have written as a skelthon, can give me advise me or correct if i am heading in the wrong dirn..Thanks a millon.
Code:
;*********************************************************************************************************************
;START OF CODE to initialize the processor****************************************************************************
;*********************************************************************************************************************
;**********************************
;Bank0 initialization starts first*
;**********************************
Start movlw 0x07 ;Turn comparators off
movwf CMCON
bcf STATUS,RPO ;Select bank0
bcf STATUS,RP1
clrf PORTA ;Initialize PORTA by clearing the output latches
clrf PORTB ;Initialize PORTB by clearing the output latches
clrf delay1
clrf delay2
; *************************************
;Most Bank 1 initializations come next*
; *************************************
bsf STATUS,RP0 ;select bank 1
movlw b'11111100'
movwf TRISB ;set PortB as 2 outputs and 6 inputs
bcf STATUS,RP0 ;REvert back to bank 0
bsf INTCON,GIE ;Global interrupts enabled
bsf INTCON,RBIE ;interrupt upon pin change enabled
loop goto loop ;Wait for interrupt??
;****************************************************************************************************************************
;This routine checks for the 6 inputs if they have been pressed at all, if they are pressed that subroutine
;will be called, if the buttons are not pressed it will go back and check the state of the buttons.
chkpress bcf INTCON,RBIF ;Clears RB interrupt flag to enable for other interrupts to occur in main prg
btfss PORTB,MINbutton ;Chk which pin causes the interrupt and call the subroutine to handle the interrupt
goto MINpress
;call MINpress
btfss PORTB,SECbutton
goto SECpress
;call SECpress
btfss PORTB,START
goto STARTpress
;call STARTpress
btfss PORTB,STOP
goto STOPpress
;call STOPpress
btfss PORTB,RESET
goto RESETpress
;call RESETpress
btfss PORTB,TXbutton
goto TXpress
;call TXpress
;**********************************************************
;Shd i use a polling system or interrupt based approached?*
;**********************************************************
retfie ;Main pbm, i have 6 inputs which must be interrupted once pressed but rbie acts upon pins 4 to 7, how??
;goto chkpress ;Loop back and wait for change of state in buttons
;Subroutines for cases when the buttons are pressed
MINpress call SWdebounce ;Call delay to allow for debounce to settle
btfss PORTB,MINbutton ;Check if the button is still pressed
retlw 0x000 ;Return if it is not pressed
goto INC_DECmin ;If pressed, call subroutine
retfie
SECpress call SWdebounce ;Call delay to allow for debounce to settle
btfss PORTB,SECbutton ;Check if the button is still pressed
retlw 0x000 ;Return if it is not pressed
goto INC_DECsec ;If pressed, call subroutine
retfie
STARTpress call SWdebounce ;Call delay to allow for debounce to settle
btfss PORTB,START ;Check if the button is still pressed
retlw 0x000 ;Return if it is not pressed
goto START ;If pressed, call subroutine
retfie
STOPpress call SWdebounce ;Call delay to allow for debounce to settle
btfss PORTB,STOP ;Check if the button is still pressed
retlw 0x000 ;Return if it is not pressed
goto STOP ;If pressed, call subroutine
retfie
RESETpress call SWdebounce ;Call delay to allow for debounce to settle
btfss PORTB,RESET ;Check if the button is still pressed
retlw 0x000 ;Return if it is not pressed
goto RESET ;If pressed, call subroutine
retfie
TXpress call SWdebounce ;Call delay to allow for debounce to settle
btfss PORTB,TXbutton ;Check if the button is still pressed
retlw 0x000 ;Return if it is not pressed
goto TX ;If pressed, call subroutine
retfie
This is how i intend to approach my problem, being a first time programmer to pic, i will welcome all useful comments or advice from all of u..Thanks once again.