dittoThank you very much for the pointers and help. It's been a fun experiment and I've learned a lot.
and I finally figured out what I was doing wrong with asm psect labels
Warning I'm not a teacher
whats next
a ttf
a double size font for digits (0 to 9 +- : )
Warning I'm not a teacher
Hi Richard,
Thanks for the fix on the single char problem, it works well but I've found another problem...
When I add DT Ints the big characters don't work, I tried with and without using mssp but same result.
Also there's something strange taking place with the led backlight insomuch as I need to sprinkle port pin enable code immediately following any lcd write (with or without DT Ints). I tried changing LCD_LIGHT from A.0 to A.1 (while leaving it connected to A.0) with no difference - does the Inc file employ any commands for the light?
Here's the edited code:
Is the Inc file compatible with DT Ints?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=%00000000 'TRISB=%00000000 TRISB=%11101011 ; Encoder inputs on B5-7 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--------------- ' LCD_CLK var Portb.4 ' Clock ' LCD_DIN var Portb.2 ' Data Include "Modedefs.bas" INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP type interrupts Include "nokia_ds.INC" ' bring it in include "font7x5_16.bas" 'include "font7x5_16 edit degC.BAS" ; use @ to access degC symbol. 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 PortA.0 = 0 ' turn on backlight. PAUSE 1000 LCDCLR PAUSE 1000 looper: LCDCLR PortA.0 = 0 ' turn on backlight. 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" PortA.0 = 0 ' turn on backlight. ' 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. PortA.0 = 0 ' turn on backlight. PAUSE 1000 GOTO looper Rot_Encoder: ' if PortB.7 = 0 then ' Check if Encoder pushbutton was pushed. ' ButtPush = 1 ' Set the flag for a quick exit. ' Old_Bits = New_Bits ' Equalize the disturbance the pushbutton caused. @ INT_RETURN ; Exit accordingly. ' endif END
Regards,
Bill
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
Warning I'm not a teacher
some pics of the big fnt
Warning I'm not a teacher
Nice work, Richard. This stuff is addicting...
I worked through my problems with XC8 and have put aside the "minimal overhead" 5x7 project for now (stopping at 370 words total). Now I'm lookin' at bigger fonts, too, and a driver that can use an hpos (0..83) and vpos (0..47) starting point for drawing characters.
I looked at someone's 11x16 font (below left) but I don't like it as much as a 10x14 font from Noritake-Itron (below right). I think I'd like to use the Noritake font as a starting point and reduce the character size slightly to allow for descenders on a few select lower case characters.
Take care... Have fun... Regards, Mike
Last edited by Mike, K8LH; - 28th May 2018 at 19:45.
Hi Richard,
I finally found some time to try your suggestions as shown in post #41 - it does not work for me.
Copying and pasting your code, I had no display until changing TRISA from %10010000 to all outputs and even then no big characters were seen until DTints and associated parts were commented out. Order of Includes made no difference.
There's still a problem with the backlighting as well because it initially is dim then changes to a short duration pulse of bright background coincident with each LCDCLR command. No difference whether displaying big characters or not wrt these bright flashes. When I add LCD_LIGHT = 1 in the mix I have no text displayed.
Any suggestions where I should go to from here?
Thanks and regards,
Bill
my code as posted works perfectly for me , so I'm not sure what the problem is.I finally found some time to try your suggestions as shown in post #41 - it does not work for me
Any suggestions where I should go to from here?
if you post your latest code attempt and refresh my memory on how its connected I will have a look.
Warning I'm not a teacher
include order does not seem to matter [as I hoped]
INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
INCLUDE "ReEnterPBP.bas" ' Include if using PBP type interrupts
Include "nokia_ds.INC" ' bring it in
include "font7x5_16.bas"
works fine
Warning I'm not a teacher
a version with fonts of user defined size
this has a 14x10 font for two char 0,1 ie 2 rows 10 columns
fonts now have a header added to define rows/columns first chr and last chr
eg
Code:#asm psect FONT_table,class=CODE,local,delta=2 GLOBAL _FNT _FNT DW 0X0501, 0X207F //1 ROW 5 COL CHR 32-127 DW 0x0000, 0x0000, 0x0000, 0x005F, 0x0000 // 32 ' ' '!' DW 0x0007, 0x0007, 0x0014, 0x3F94, 0x3F94 // 34 '"' '#' DW 0x122A, 0x3FAA, 0x0923, 0x0988, 0x3262 // 36 '$' '%' ...............................
Code:/** Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2 Device : PIC16F1847 Driver Version : 2.00 * font.c included via ide source files */ #include "mcc_generated_files/mcc.h" void putwreg(char work); void putcmd(char x); void WrChar(char ); void WrStr(const char *); void set_fnt(const char *); extern const char FNT,NUM; uint16_t fnt_addr; char fnt_row,fnt_col,fnt_fc,fnt_lc,POSX,POSY; void main(void) { // initialize the device SYSTEM_Initialize(); set_fnt(&FNT); /* * * initialize Nokia 5110 LCD display * * */ __delay_ms(30); // LCD_RST_SetLow(); // 5110 'reset' pulse __delay_ms(1); LCD_RST_SetHigh(); // 5110 'reset' pulse __delay_ms(1); putcmd(0x20 + 0x01); // function set: extended instructions putcmd(0xc8); // set Vop (contrast), 0..127 putcmd(0x04 + 0x02); // set temperature coefficient, 0..3 putcmd(0x10 + 0x03); // Set bias system, 0..7 putcmd(0x20 + 0x00); // function set: standard instructions putcmd(0x08 + 0x04); // display control: normal mode putcmd(0x80 + 0x20); // set DDRAM X address, 0..83 putcmd(0x40 + 0x02); // set DDRAM Y address, 0..5 POSX=32; POSY=2; WrChar('R'); // write ascii character WrStr("eady"); set_fnt(&NUM); putcmd(0x80 + 0x10); // set DDRAM X address, 0..83 putcmd(0x40 + 0x04); // set DDRAM Y address, 0..5 POSX=16; POSY=5; WrChar('0'); // write ascii character WrChar('1'); // write ascii character while (1) { } } /** End of File */ void set_fnt(const char *F){ uint16_t tmp; fnt_addr=(uint16_t)F&0x1fff; tmp=FLASH_ReadWord(fnt_addr++); fnt_row = (char)tmp; fnt_col = tmp>>8; tmp=FLASH_ReadWord(fnt_addr++); fnt_lc = (char)tmp; fnt_fc = tmp>>8; } void putwreg(char work) // send byte, msb first (15 words) { LCD_CE_LAT = 0; // spi enable on SPI1_Exchange8bit(work); LCD_CE_LAT = 1; // spi enable off } // void WrChar(char d) { // for packed 2.5 word 5x7 font uint16_t tmp, inx = fnt_addr; char fd[32], i = fnt_row, j = 0, k, *pt; if ((d < fnt_fc) || (d > fnt_lc))return; inx += ((d - fnt_fc) * fnt_col*fnt_row) >> 1; while (i--) { k = fnt_col >> 1; if (k == 2)k++; while (k--) { tmp = FLASH_ReadWord(inx++); if (!i) fd[j + 1] = ((char)tmp & 0x7f) ;//<< 1 else fd[j + 1] = ((tmp & 0x7f)<<1)&0xfe; tmp <<= 1; if (!i) fd[j] = (tmp >> 8)& 0x7f; else fd[j] = (tmp >> 7)& 0xfe;; j += 2; } } pt = fd; if ((d & 1)&&(fnt_col == 5))pt++; i = fnt_row; while (i--) { k = fnt_col; putcmd(0x40 +POSY-i); if(!i){ putcmd(0x80 +POSX); } // with font now stored in bufer fd its easy to have large and/or inverted text while (k--) { putwreg(*pt++); } putwreg(0); } POSX+=fnt_col+1; } void putcmd(char x) { LCD_DC_SetLow(); putwreg(x); LCD_DC_SetHigh(); } void WrStr(const char *buff) { { // while (*buff) WrChar(*buff++); // } } #asm psect nums_table,class=CODE,local,delta=2 _NUM DW 0X0A02, 0X3031 //2 ROW 10 COL CHR 0,1 DW 15998, 899 ,8691, 15775 ,16252 // chr 0x30 " 0 " DW 4031, 15486, 14307, 12400, 8095 DW 0, 518, 16383, 0, 0 // chr 0x31 " 1 " DW 64 ,8288 ,16383 ,12352, 8192
Last edited by richard; - 28th May 2018 at 05:52.
Warning I'm not a teacher
IT needed a tweak to work for a 18f26k22
Warning I'm not a teacher
Bookmarks