works perfectly if done correctly the include's order may matter, ioc int needs to configured
if your programmer is still connected to portb.7 that can load things up a bit [I leave mine connected and avoid using b6,b7 pins]
never use portx.x to set or clear pins , its just asking for rmw problems especially with fast fosc settings
always use latx.x when available or use a shadow register
Code:#CONFIG ; 16F1847. __config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _BOREN_OFF __config _CONFIG2, _PLLEN_OFF & _LVP_OFF #ENDCONFIG @ ERRORLEVEL -306 ; turn off crossing page boundary message ; --- *** Oscillator *** --------------------------------------------------- define OSC 32 OSCCON = %11110000 ; 32 MHz, ANSELA = 0 ; all digital ANSELB = 0 ; all digital TRISA=%10010000 'TRISB=%00000000 TRISB=%11101011 ; Encoder inputs on B5-3 IOCBN = %00101000 ;enable ioc falling edge b3,b5 ch var byte BUFF VAR BYTE [10] ;DEFINES FOR DISPLAY use font7x5_16.bas or font7x5_18.bas for pic18 #DEFINE PIC16 1 #define use_mssp 1 ; much faster and less words (1027 vs 1106). lcdheight con 5 ; 6 PAGES lcdwidth con 83 ; 84 PIXELS WIDE LCD_RST var LATA.4 LCD_DC var LATA.3 LCD_CE var LATA.6 LCD_LIGHT var LATA.0 ;LCD_CLK var LATB.4 ' SCK1 pin needs to be set as dig o/p ;LCD_DIN var LATB.2 ' SDO1 pin needs to be set as dig o/p ;--------------ONLY IF MSSP NOT USED--------------- ' Include "nokia_ds.INC" ' bring it in include "font7x5_16.bas" INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP type interrupts ' ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler IOC_INT, _Rot_Encoder, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE IOC_INT ; Port Change Interrupt '========================== MAIN Routine ============================== gosub lcd_init LCDCLR ARRAYWRITE BUFF,["READY",0] LCDSTR 5,0,BUFF LCD_LIGHT = 0 ' turn on backlight. PAUSE 1000 LCDCLR PAUSE 1000 looper: LCDCLR bigtxt = 1 ; double size chrs LCDSTR 0,0,"Noki+12" LCDSTR 0,2,"345678@" bigtxt = 0 ; normal size chrs ' LCDSTR 52,3,"Demo" ' LCDSTR 0,4,"With@MSSP xfer" LCDSTR 0,4,"Hi" ' LCDSTR 0,5,"Dble Size Chrs" ' LCDSTR 0,5," " ; this doesn't compile - causes errors and warnings wherever used. LCDC 0,5,"a" ; use LCDC for single chars. PAUSE 1000 GOTO looper Rot_Encoder: if IOCBF.3 then LCD_LIGHT = 0 ' Check if button was pushed. if IOCBF.5 then LCD_LIGHT = 1 IOCBF=0 @ INT_RETURN ; Exit accordingly. ' endif END




Bookmarks