RBC_INT only triggers on chages with PORTB<7:4>
For PORTB.0, you would use INT0_INT
PORTB.1 is INT1_INT
Each one should have it's own handler, so it automatically knows which pin triggered.
<br>
RBC_INT only triggers on chages with PORTB<7:4>
For PORTB.0, you would use INT0_INT
PORTB.1 is INT1_INT
Each one should have it's own handler, so it automatically knows which pin triggered.
<br>
DT
Keep in mind that any changes on PORTB.6 or 7 will also trigger an interrupt. It's best to Not Use 6 and 7 for anything else.
Code:Old_Bits VAR BYTE New_Bits VAR BYTE INCLUDE "DT_INTS-18.bas" ' Base Interrupt System INCLUDE "ReEnterPBP-18.bas" ' Include if using PBP interrupts ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RBC_INT, _RBC_handler, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM Old_Bits = PORTB @ INT_ENABLE RBC_INT ;RB Port Change Interrupt Main: Pause 1000 GOTO Main '---[RBC - interrupt handler]--------------------------------------------------- RBC_handler: New_Bits = PORTB IF (New_Bits.4 <> Old_Bits.4) THEN ; -- PORTB.4 has changed -- ENDIF IF (New_Bits.5 <> Old_Bits.5) THEN ; -- PORTB.5 has changed -- ENDIF Old_Bits = New_Bits @ INT_RETURN
DT
Darrel, I know this statement was related to a posting for a 18F66J15, but I am trying to use RBC_INT for PortB.2 and PortB.3 on a 16F886. I had a design going on a 18F2550 that used INT2_INT on PortB2 and worked well. However, for reasons I won't go into here I had to move the design to a 16F886 and continue to use PortB.2 and PortB.3 as interrupt inputs from the alarm pins on a DS1337 RTC. I already have PCBs built originally for the 28-pin 18F2550 and am trying to salvage them without trace changes by substituting a 28-pin 16F886 on the same board layout. My question...is there anyway I can use RBC_INT on the PortB.2 and PortB.3 pins of a 16F886 and monitor which pin actually received the interrupt? I have noted your OLDPORT vs NEWPORT technique to do this kind of interrupt isolation and presume I can do this on my 16F886 if RBC_INT will work ont these ports? Can you help me out here?
John,
On the 16F88x's use IOC_INT (Interrupt On Change).
Set the pins you want to monitor in the IOCB register.
DT
OK, Darrel...I got rid of the On Change interrupt related statements in my code and set up for the IOC_INT per following.
However I get the following assembler errors which made me go into the .lst file to see where the problem was but I can't locate what is causing these errors. Can you tell me?Code:;--- Setup Interrupts ---------------------------------------------------- ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler IOC_INT, _Alarm, PBP, yes ; INT_Handler LVD_INT, _VoltLow, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE IOC_INT ; enable IOC interrupts ' Per DT, DT_INTS already takes care of setting registers ' but this code doesn't work unles below registers set as indicated: IOCB.2= 1 ' ENABLE IOC INERRUPT ON PORTB.2 (RB2) for Alarm1 TRISB = %00011100 ' RB2 & RB3 set as RTC Alarm1 & Alarm2 inputs ' PORTB.2 is also an interrupt from manual switch GND ' PORTB.4 is set for input as A/D Channel 11 WPUB = 0 ' DISABLE all PortB pull-ups CM1CON0 = 0 ' DISABLE COMPARATORS CM2CON0 = 0 ' DISABLE COMPARATORS
Warning[205] C:\PBP26\ELLIS_CODES\RTC\16F886\0SETDS1337CLOCK.AS M 364 : Found directive in column 1. (endm)
Warning[207] C:\PBP26\ELLIS_CODES\RTC\16F886\0SETDS1337CLOCK.AS M 551 : Found label after column 1. (INT_ENABLE)
Error[122] C:\PBP26\ELLIS_CODES\RTC\16F886\0SETDS1337CLOCK.AS M 551 : Illegal opcode (IOC_INT)
Discovered I had forgotten to uncomment the follwoing statements required for using DT_INTS.
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP high priority interrupts
However, after fixing that however, I still have the following assembly errors I can't figure out:
Error[101] C:\PBP26\ELLIS_CODES\RTC\16F886\0SETDS1337CLOCK.AS M 790 : ERROR: ("INT_Handler" - Interrupt Flag ( INTCON,IOCIF ) not found.)
Error[101] C:\PBP26\ELLIS_CODES\RTC\16F886\0SETDS1337CLOCK.AS M 790 : ERROR: ("INT_ENABLE" - Interrupt Flag ( INTCON,IOCIF ) not found.)
Looked in .lst file for the above errors and found both.
This one is strange because it indicates INTERRUPT_handler was not labeled with PBP...it was. Can you tell me from this why the error?
For this error I can't see why the FlagBit wasn't set. Can you explain this error to me?Code:M if (PBP == PBP) ; If INT handler is PBP M ifdef ReEnterUsed M btfsc _Vars_Saved M goto AfterSave M GetAddress AfterSave, _RetAddr M L?GOTO _SavePBP ; Save PBP system Vars M LABEL?L AfterSave M else M error ReEnterPBP must be INCLUDEd to use PBP type interrupts M endif M endif M GetAddress AfterUserRoutine, _RetAddr ; save return address M L?GOTO _Alarm ; goto the users INT handler M LABEL?L AfterUserRoutine M M if (yes == YES) M CHK?RP INTCON M bcf INTCON, IOCIF ; reset flag (if specified) M endif M else M INT_ERROR "INT_Handler" Error[101] : ERROR: ("INT_Handler" - Interrupt Flag ( INTCON,IOCIF ) not found.) M error "INT_Handler" - Interrupt Flag ( INTCON,IOCIF ) not found. M endif
Code:00989 INT_ENABLE IOC_INT ; enable IOC interrupts M ifdef FlagBit M ifdef INT_ENABLECLEARFIRST M if (INT_ENABLECLEARFIRST == 1) ; if specified M MOVE?CT 0, INTCON, IOCIF ; clear the flag first M endif M endif M MOVE?CT 1, INTCON, IOCIE ; enable the INT source M else M INT_ERROR "INT_ENABLE" Error[101] : ERROR: ("INT_ENABLE" - Interrupt Flag ( INTCON,IOCIF ) not found.) M error "INT_ENABLE" - Interrupt Flag ( INTCON,IOCIF ) not found. M endif
Sorry, it is RBC_INT on that chip. But you still use the IOCB register like other chips with IOC_INT.
Microchip does things different everytime.
DT
Bookmarks