exelanoz
- 29th May 2008, 21:46
Hello Hello,
I used Darrel's LCD anypin the other day on a 16F628, worked great, but I am not having any luck today with the interrupts on 16F767. I am probably doing something wrong.
I have checked settings, wiring, re-read darrel's website info, but I am still missing something.
Attached is a small test code. Using external interrupt, switch pins are connected to RB0,
so when interrupt triggered, it should read pins.
I assembled it on EasyPIC4 switches are indeed pulled to ground, I can verify with the LED and also doing a simple Port status display on the LCD, so it definitely the code or the configuration.
Any help, comments, suggestions much appreciated.
'*** SWITCH / INTERRUPT TEST ***
'Setup for PIC16F767 @ 4Mhz
;Config Register 1
@ __CONFIG _CONFIG1, _CP_OFF & _CCP2_RC1 & _DEBUG_OFF & _HS_OSC &_VBOR_2_7 & _MCLR_ON & _PWRTE_OFF & _WDT_ON
;Config Register 2
@ __CONFIG _CONFIG2, _BORSEN_0 & _IESO_OFF & _FCMEN_OFF
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
DEFINE OSC 4
OPTION_REG.7 = 1 'Disable PORTB pull ups
ADCON0.0 = 0
ADCON1 = 15 'Disable ALL Analog inputs. ALL PORTS digital
TRISB = %00011111 'PortB 7,6,5 Outputs,
'Set LCD Data Port
DEFINE LCD_DREG PORTC
'Set starting Data Bit (0 or 4) if a 4-bit bus
DEFINE LCD_DBIT 4
'Set LCD Register Select Port
DEFINE LCD_RSREG PORTC
'Set LCD Register Select Bit
DEFINE LCD_RSBIT 0
'Set LCD Enable Port
DEFINE LCD_EREG PORTC
'Set LCD Enable Bit
DEFINE LCD_EBIT 3
'Set LCD Bus Size (4 or 8 bits)
DEFINE LCD_BITS 4
'Set number of lines on LCD
DEFINE LCD_LINES 2
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _Detect, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE INT_INT ; enable external (INT) interrupts
Switch_1 VAR PORTB.1
Switch_2 VAR PORTB.2
Switch_3 VAR PORTB.3
Switch_4 VAR PORTB.4
Main:
Pause 50
GOTO MAIN
'---[INT - interrupt handler]---------------------------------------------------
Detect:
If switch_1 = 1 THEN LCDOUT $FE,$80,"Switch 1"
If switch_2 = 0 THEN LCDOUT $FE,$80,"Switch 2"
If switch_3 = 0 THEN LCDOUT $FE,$80,"Switch 3"
If switch_4 = 0 THEN LCDOUT $FE,$80,"Switch 4"
@ INT_RETURN
I used Darrel's LCD anypin the other day on a 16F628, worked great, but I am not having any luck today with the interrupts on 16F767. I am probably doing something wrong.
I have checked settings, wiring, re-read darrel's website info, but I am still missing something.
Attached is a small test code. Using external interrupt, switch pins are connected to RB0,
so when interrupt triggered, it should read pins.
I assembled it on EasyPIC4 switches are indeed pulled to ground, I can verify with the LED and also doing a simple Port status display on the LCD, so it definitely the code or the configuration.
Any help, comments, suggestions much appreciated.
'*** SWITCH / INTERRUPT TEST ***
'Setup for PIC16F767 @ 4Mhz
;Config Register 1
@ __CONFIG _CONFIG1, _CP_OFF & _CCP2_RC1 & _DEBUG_OFF & _HS_OSC &_VBOR_2_7 & _MCLR_ON & _PWRTE_OFF & _WDT_ON
;Config Register 2
@ __CONFIG _CONFIG2, _BORSEN_0 & _IESO_OFF & _FCMEN_OFF
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
DEFINE OSC 4
OPTION_REG.7 = 1 'Disable PORTB pull ups
ADCON0.0 = 0
ADCON1 = 15 'Disable ALL Analog inputs. ALL PORTS digital
TRISB = %00011111 'PortB 7,6,5 Outputs,
'Set LCD Data Port
DEFINE LCD_DREG PORTC
'Set starting Data Bit (0 or 4) if a 4-bit bus
DEFINE LCD_DBIT 4
'Set LCD Register Select Port
DEFINE LCD_RSREG PORTC
'Set LCD Register Select Bit
DEFINE LCD_RSBIT 0
'Set LCD Enable Port
DEFINE LCD_EREG PORTC
'Set LCD Enable Bit
DEFINE LCD_EBIT 3
'Set LCD Bus Size (4 or 8 bits)
DEFINE LCD_BITS 4
'Set number of lines on LCD
DEFINE LCD_LINES 2
ASM
INT_LIST macro ; IntSource, Label, Type, ResetFlag?
INT_Handler INT_INT, _Detect, PBP, yes
endm
INT_CREATE ; Creates the interrupt processor
ENDASM
@ INT_ENABLE INT_INT ; enable external (INT) interrupts
Switch_1 VAR PORTB.1
Switch_2 VAR PORTB.2
Switch_3 VAR PORTB.3
Switch_4 VAR PORTB.4
Main:
Pause 50
GOTO MAIN
'---[INT - interrupt handler]---------------------------------------------------
Detect:
If switch_1 = 1 THEN LCDOUT $FE,$80,"Switch 1"
If switch_2 = 0 THEN LCDOUT $FE,$80,"Switch 2"
If switch_3 = 0 THEN LCDOUT $FE,$80,"Switch 3"
If switch_4 = 0 THEN LCDOUT $FE,$80,"Switch 4"
@ INT_RETURN