A tft addin for pbp3


Closed Thread
Page 1 of 4 1234 LastLast
Results 1 to 40 of 142
  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512

    Default A tft addin for pbp3

    The first of my tft modules arrived today a 1.8 inch st7735 with spi interface

    so far I have a scalable chr32 to 90 font and a rectangle fill utility . no one responded to my previous offer to make joint effort to develop this idea but now that I have something working it might be different . so I will have one more go ,if no one is interested I will just develop it for myself .
    this is just a demo and not documented at all ( it would be a waste of time if there is no interest)
    Attached Files Attached Files

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    a photo of the output
    Attached Images Attached Images  

  3. #3
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Very nice. And nice example for using USERCOMMAND

  4. #4
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    That's very nice!

    yes, please do share... I'd live to try one of those little displays.

    thanks
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    glad to see some interest

    some ideas needed :-

    currently to display a string
    Code:
    fg=$F800  ; set colour
     TEXTSIZE=2 
     ARRAYWRITE buffer,["HELLO WORLD",0]
     GLCDC 1,63     ; set x ,y position
     ch=0
     WHILE (ch< 32) AND (buffer[ch]>0  )  ; check for end of string
     GLCDC  buffer[ch]        ; disp ch
     ch=ch +1
     WEND
    I would rather have a usercommand

    GLCDS 1,63 ,buffer
    but I can't figure a way of getting the address of buffer from the usercommand macros
    GLCDS 1,63 ,"HELLO WORLD"
    but I can't figure a way of getting the string data from the usercommand macros

    I would like to put the display hardware dependent code into a separate include file (that way other displays could be incorporated)
    not all the useful input combinations have had their macros written for each user command
    more user commands are required
    drawHline,drawVline,drawline,drawcircle,drawrect,f illcircle


    the hardware connection interface is defined like this
    Code:
      tft_dc_bit con 4
      tft_cs_bit con 1
      tft_rst_bit con 8
      tft_port var latd
    its a bit clunky I sure there are better ways

    bit banging the data could be investigated

    over to you

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    another pic
    Attached Images Attached Images  

  7. #7
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Never done something like that, but as DT said there is no better manual than .mac and .lib files.
    So here is what I found.

    Compiler use this macro from pbppic18.mac file when LCDOUT STR is used
    Code:
    ;****************************************************************
    ;* LCDOUTSTR?B : Macro - Lcdout string                          *
    ;*                                                              *
    ;* Input      : B[]                                             *
    ;* Output     : None                                            *
    ;*                                                              *
    ;* Notes      :                                                 *
    ;****************************************************************
    
    LCDOUTSTR?B macro Bin
            MOVE?CW LCDOUTJ, R8 'dont know what this line do
    	MOVE?CB	high (Bin), FSR2H 'load highbyte of adr, from pbppic18.lib Macro - Move BYTE Variable into WORD Variable
            MOVE?CA	low (Bin) 'load low byte of adr to w, from pbppic18.lib MOVE?CA    : Macro - Move constant into W 
     
            L?CALL  SEROUT2STR
        endm
    SEROUT2STR is in file pbppic18.
    Code:
    SEROUT2STR movwf FSR2L          ; Set up for index
    serout2strloop movf POSTINC2, W	; Get a character
    	bnz	serout2str1	; Not null char
    So you could use in your program something like this:
    Code:
    TFTSTR?B macro Bin
    	MOVE?CB	high (Bin), FSR2H ;load highbyte  
            MOVE?CB	low  (Bin), FSR2L ;load low byte  
    local tftstrloop 
    local tftStrDone
    tftstrloop movf POSTINC2, W	; Get a character, then increment pointer
            BZ  tftStrDone ;All strings must end with 0
           ;Not Null char 
            L?CALL tftWoutput; CALL print char in W to TFT 
            BRA tftstrloop ;Get next chr
          
    tftStrDone: ;Null char
    
    endm ;end of macro
    EDIT:
    You could also use PBP's routine like LCDOUTSTR do, but you must see what this flags do
    LCDOUTJ_USED = 1
    SEROUT2STR_USED = 1
    And how JUMPMAN is used.
    Last edited by pedja089; - 22nd June 2015 at 03:11.

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Hi Richard,
    Where is the subroutine tft_init ?
    I have ordered 2 from your seller should get then before Christmas . . .
    These look very promising .. .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    updated version , complete this time {end must have fallen off first time}
    Attached Files Attached Files

  10. #10
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    MOVE?CB high (Bin), FSR2H ;load highbyte
    MOVE?CB low (Bin), FSR2L ;load low byte
    that's what I was looking for thanks pedja089

  11. #11
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    that's one down , works like a dream
    Code:
    GLCDSTR?CCB  macro Xin ,Yin ,Bin
            movlw    Xin
            CHK?RP    _X
            MOVWF     _X
            movlw    Yin
            CHK?RP    _Y
            MOVWF     _Y
            MOVE?CB high (Bin), FSR2H ;load highbyte 
            MOVE?CB low (Bin), FSR2L ;load low byte
    strloop movf POSTINC2, W ; Get a character
            bnz outstr1 ; Not null char 
            bra exstr
    outstr1 MOVWF _g_chr   
            L?CALL _gcga  
            bra   strloop
    exstr   
        endm

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    woops - looping in macro for multiple calls is a no go
    needs to be like this

    Code:
    GLCDSTR?CCB  macro Xin ,Yin ,Bin
            movlw    Xin
            CHK?RP    _X
            MOVWF     _X
            movlw    Yin
            CHK?RP    _Y
            MOVWF     _Y
            MOVE?CB high (Bin), FSR2H ;load highbyte 
            MOVE?CB low (Bin), FSR2L ;load low byte
            L?CALL  bfill
      
        endm           
    
    
      
    bfill
    Next_Char 
            movf POSTINC2, W	; Get a character
            bnz	outchr	; Not null char 
            bra exstr2
    outchr	MOVWF _g_chr 
            L?CALL _gcga  
            bra   Next_Char 
    exstr2  return

  13. #13
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    now have strings and circles, moved font to include file


    USERCOMMAND?S
    HOW TO USE THIS STILL ELUDES ME would be nice for display of "constant" string
    Attached Images Attached Images  
    Attached Files Attached Files

  14. #14
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    You can use label in macro and multiple call to that macro.
    Just need to define your labels as local.
    Here is local used in my example:
    Code:
    TFTSTR?B macro Bin
    	MOVE?CB	high (Bin), FSR2H ;load highbyte  
            MOVE?CB	low  (Bin), FSR2L ;load low byte  
    local tftstrloop 
    local tftStrDone
    tftstrloop movf POSTINC2, W	; Get a character, then increment pointer
            BZ  tftStrDone ;All strings must end with 0
           ;Not Null char 
            L?CALL tftWoutput; CALL print char in W to TFT 
            BRA tftstrloop ;Get next chr
          
    tftStrDone: ;Null char
    
    endm ;end of macro
    But way your done use less FLASH
    And you can make bfill little smaller
    Code:
    bfill
    Next_Char 
            movf POSTINC2, W	; Get a character
            bz	exstr2  ; Null char 
     	    MOVWF _g_chr 
                L?CALL _gcga  
                bra   Next_Char 
    exstr2  return
    To save few bytes in FLASH.
    And I'll suggest you to put TFT_ in front all labels and variable names so there is minimal chance for user to duplicate label/variable or unintentional use one of tft variables.

  15. #15
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    And for "Constant String" I don't know how to implement it with user command. But I know assembler part
    Here is use of asm macro
    PrintStr 0,0," Test Clock"
    And macro:
    Code:
    PrintStr macro x, y, Str
     local TheString, OverStr ; define local labels so you can call macro multiple times
     goto OverStr ' goto over string stored in FLASH, so processor can't execute that
    TheString ;label to get address of your string
     data Str, 0 ;add string to flash at TheString address and end string with 0
    OverStr
     MOVE?CB x, _GLCD_X
     MOVE?CB x, _GLCD_SX
     MOVE?CB y, _PosY
     MOVE?CW TheString, _GLCD_Addr ;move addres of string to word variable, don't know how it would work with device that have more than 65535K of FLASH???
     L?CALL _GLCD_StringOut 
     endm
    ENDASM
    
    GLCD_StringOut:
    Readcode GLCD_Addr, GLCD_Char ' Get a character
    if GLCD_Char = 0 then RETURN ' Look for Null char, Stop if found
    ......
    RETURN
    This is from example for nokia 3310 lcd, that I tried to get to work with GLCD with KS0108 controler.
    Last edited by pedja089; - 22nd June 2015 at 13:55.

  16. #16
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Just need to define your labels as local.
    brilliant , thanks for the tip pedja089

    And for "Constant String" I don't know how to implement it with user command
    seems nobody does

    I might just stick to my flash2ram macro for now

  17. #17
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    now with drawline and a bit of optimising
    I will wait now for my 2.8" ILI9340C tft display to arrive and see if I can separate out a hw include for each type
    Attached Files Attached Files

  18. #18
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Compiler know how to handle user command with string.
    So lets try to get something...
    Try this code:

    Code:
    GLCD_Addr var word
    GLCD_Char var byte
    asm   
    ;----[String]---------------------------------------------------------------
    GLCDC?S  macro Cin
     local TheString, OverStr ; define local labels so you can call macro multiple times
     goto OverStr ; goto over string stored in FLASH, so processor can't execute that
    TheString ;label to get address of your string
     data Cin, 0 ;add string to flash at TheString address and end string with 0
    OverStr
     MOVE?CW TheString, _GLCD_Addr ;move addres of string to word variable, don't know how it would work with device that have more than 65535K of FLASH???
     L?CALL _GLCD_StringOut 
     endm
    
     ENDASM
    GLCD_StringOut:
    Readcode GLCD_Addr, GLCD_Char ' Get a character
    if GLCD_Char = 0 then RETURN ' Look for Null char, Stop if found

  19. #19
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    that's got it

    Code:
    GLCD_StringOut:
    Readcode GLCD_Addr+j, g_chr ' Get a character
    if  g_chr = 0 then RETURN ' Look for Null char, Stop if found
    j=j+1
    gosub gcga 
    goto   GLCD_StringOut
    Code:
    ;----[String]---------------------------------------------------------------
    GLCDC?S  macro Cin
     local TheString, OverStr ; define local labels so you can call macro multiple times
     goto OverStr ; goto over string stored in FLASH, so processor can't execute that
    TheString ;label to get address of your string
     data Cin, 0 ;add string to flash at TheString address and end string with 0
    OverStr
      movlw   0
      CHK?RP    _j
      MOVWF     _j
     MOVE?CW TheString, _GLCD_Addr ;move addres of string to word variable, don't know how it would work with device that have more than 65535K of FLASH???
     L?CALL _GLCD_StringOut 
     endm
    good work

  20. #20
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    You don't need J var. Just increment GLCD_Addr.
    Code:
    GLCD_StringOut:
    Readcode GLCD_Addr, g_chr ' Get a character
    if  g_chr = 0 then RETURN ' Look for Null char, Stop if found
    GLCD_Addr=GLCD_Addr+1
    gosub gcga 
    goto   GLCD_StringOut
    And If you need to clear variable, you always can use CLRF, it's just shorter then loading 0 to w then from W to variable.
    And if you want to avoid CHK?RP, declare variable to BANKA.

  21. #21
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,569


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Hi,
    This is great stuff, very nice work!
    I will wait now for my 2.8" ILI9340C tft display to arrive and see if I can separate out a hw include for each type
    May I suggest that you instead look into the posibillity of having it all in one file or set of files and make use of conditional compilation features to select between the targeted controller?

    /Henrik.

  22. #22
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    You don't need J var. Just increment GLCD_Addr.
    good idea, the extra eyes are very handy

    and henrik
    I'm not sure how different the hardware will be , when I set it up your very welcome to contribute some conditional compilation expertise.
    the more heads we get working on this sort of thing the better. if arduino can have a free lib for everything at least we could have something for popular devices.
    maybe some public domain free addins will breathe a bit of life back into pbp.
    I feel that now that usefulness of usercommand macros are endless and have been largely unexplored on the forum

  23. #23
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    And if you want to avoid CHK?RP, declare variable to BANKA.
    the book says that to declare a variable in BANKA is not guaranteed its just a suggestion to the compile process. if this is just an addon to a much larger project I'm thinking CHK?RP is probably a good thing just in case
    but I'm open to suggestion

  24. #24
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    If variable doesn't fit into BANKA, then MPASM show error.
    Used almost in all my project, and always worked fine. Also when coding in ASM, I use SYSTEM, so there is no annoying underscore in front of variable name.
    EDIT:
    From manual:
    BANKx Instructs PBP to locate the variable in a specific bank of RAM.
    If things as address of variable, and bank of variable not guarantied if you specify them, then that is idiotic
    I'm sure if you specify location and bank of variable, compiler will try to fit in that location, otherwise throw error or at last warning.
    Last edited by pedja089; - 23rd June 2015 at 12:41.

  25. #25
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    circles and lines and constant string
    Attached Images Attached Images  
    Attached Files Attached Files

  26. #26
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Quote Originally Posted by pedja089 View Post
    If variable doesn't fit into BANKA, then MPASM show error.
    Used almost in all my project, and always worked fine. Also when coding in ASM, I use SYSTEM, so there is no annoying underscore in front of variable name.
    EDIT:
    From manual:
    BANKx Instructs PBP to locate the variable in a specific bank of RAM.
    If things as address of variable, and bank of variable not guarantied if you specify them, then that is idiotic
    I'm sure if you specify location and bank of variable, compiler will try to fit in that location, otherwise throw error or at last warning.
    yet in 7.3
    You can suggest to PBP a particular bank to place the variable in:
    penny VAR WORD
    BANK0
    nickel VAR BYTE
    BANK1
    If specific bank requests are made, those are handled first. If there is not enough room in a requested bank, the first available space is used and a warning is issued.




    but you get a warning

  27. #27
    Join Date
    Sep 2009
    Posts
    750


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    I newer see that syntax...
    I use pdf that came with PBP 3
    PICBASIC PRO™ Compiler
    REFERENCE MANUAL
    Revised March 6, 2013

    Bank should be stated after variable type.
    eg
    ticker VAR BYTE BANK0 SYSTEM 'Creates "ticker" as a BYTE in BANK0, with no Assembly prefix character
    wsave VAR BYTE $70 'Creates "wsave" at RAM address 0x70 (hex)

  28. #28
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,569


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Richard,
    I'd be happy to help if I can. You're WAY ahead of me with the usercommand and assembly type stuff so I just sit back and admire your work.

    Unfortunately the forum (or my computer(s)) no longer allows me to download any attachments. Even when logged all it serves me is a file called attachment.php. Had that happen before, then it worked with another computer but not any more.

    /Henrik.

  29. #29
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,980


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    I have this problem too. But if I rename the file it opens normally.

    Ioannis

  30. #30
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Quote Originally Posted by pedja089 View Post
    I newer see that syntax...
    I use pdf that came with PBP 3
    PICBASIC PRO™ Compiler
    REFERENCE MANUAL
    Revised March 6, 2013

    Bank should be stated after variable type.
    eg
    ticker VAR BYTE BANK0 SYSTEM 'Creates "ticker" as a BYTE in BANK0, with no Assembly prefix character
    wsave VAR BYTE $70 'Creates "wsave" at RAM address 0x70 (hex)
    the forum messes with the white space so the layout of my post was a bit off looking, but look at your reference manual pdf section 7.3 ram allocation page 265 ,thats what I'm referring to.

  31. #31
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    The 2.2 " ili9341 (ili9340c how do tell) arrived today , after resoldering all the dry joints on the module it works .
    I have separated things out like this main pbp pgm --- usercommand pbpmod file , an include bas file for either st7735 or ili9341 and a font bas file


    in the pbp file
    your hardware connections
    Code:
    ;----GLOBAL----HW---------   
        SSP_IF VAR PIR3.7      ; must match your spi port 
       tft_dc_bit con  32     ;5      binary weighted pin values 
        tft_cs_bit con 16   ;4 
        tft_rst_bit con 128   ;7
        tft_port var lath ;          ; the output port for control signals
    includes

    Code:
        INCLUDE "glcd_chr.pbpmod"        ;glcdc
        include "tft-ILI9431.bas"      one or the other  not both
    ;    include "tft-ST7735.bas"      one or the other  not both
    
        INCLUDE "DT_INTS-18.bas"
        INCLUDE "ReEnterPBP-18.bas"
        INCLUDE "Elapsed_INT-18.bas"
        INCLUDE "font7x8.bas"
    in the usercommand file glcd_chr
    WIDTH con 320;160 X
    HEIGHT con 240; 128 Y
    set to appropriate values

    and this bit needs to match your spi port too a definite conditional compile potential here
    Code:
         
    TFT_CMD:
    spi_cbyte :
        tft_port =  tft_port & (~ tft_dc_bit )
    TFT_DATA:    
    spi_byte :
    @       movff    INTCON , _p_int 
    @       bcf     INTCON ,7 
        tft_port =  tft_port& (~ tft_cs_bit )
        SSP_IF = 0
        SSP2BUF = CMD 
        WHILE   SSP_IF =0 ' wait for SPI interupt flag
        wend
        tft_port = tft_port |   ( tft_dc_bit|  tft_cs_bit   )
        
    @     movff  _p_int  , INTCON 
    return

    and off you go

    I would have liked to have the hw connections and the height width in the relevant hw include file but that presented too many issues for me
    Attached Files Attached Files

  32. #32
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    forgot the happy snap
    Attached Images Attached Images  

  33. #33
    Join Date
    Oct 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    HELLO Richard,
    If you could give me some explanations about connections of the LCD display on PIC processor.
    I just ordered one piece from eBay and on it I have these pins:


    LCD DISPLAY ILI9341 --------> PIC-PROCESSOR
    VCC---->3.3V
    GND--->ground
    LED--->
    CS---->
    D/C------->
    RESET---->
    SDI------>
    SDO----->
    SCK------->

    I don't now how to connect it on PIC?
    Last edited by visnja30; - 26th June 2015 at 23:02.

  34. #34
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    cs,d/c,reset all need to be on the same port / sdi and sck connect to a h/w spi port (adjust code to suit)

    LCD DISPLAY ILI9341 --------> PIC-PROCESSOR
    VCC---->3.3V ( seems to be ok with 5v the board has an onboard regulator) but 3.3v works too
    GND--->ground
    LED---> -----------3.3v
    CS----> in my example porth.4
    D/C-------> in my example porth.5
    RESET----> in my example porth.5
    SDI------> in my example portd.4 sdo2 on pic
    SDO-----> n/c
    SCK-------> in my example portd.6 sck2 o pic

    st7735 is the same but has no sdo pin

  35. #35
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Hi Richard,

    I am keen to replicate the great work you are doing with these TFT displays.
    I have looked on eBay for an ILI9341 display and there appears to be a gazillion of them to choose from.
    Can you share information on the eBay seller you bought your display from?

    Cheers
    Barry
    VK2XBP

  36. #36
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    hi barry ,these are what I used I'm sure the others would be ok too just make sure the I/f is spi
    http://www.ebay.com.au/itm/271683495...%3AMEBIDX%3AIT
    http://www.ebay.com.au/itm/191534577...%3AMEBIDX%3AIT

  37. #37
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Thanks Richard.

    I have now placed an order and hope to take delivery some time in July.

    Cheers
    Barry
    VK2XBP

  38. #38
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Very nice work Richard!
    ILI9341 based TFT display with resistive touch screen could be the module that I was searching.
    With STMPE610 touch controller (SPI/I2C) it would be easy to make systems that do not need any additional input devices (buttons/joystick).

  39. #39
    Join Date
    Oct 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Hi Richard

    I am little confused how to adjust code to work.
    I have a PIC18F45K22 and I plan to use it with your code but I never work with this PIC processor and I need some Help to configure it.


    From datasheet of PIC18F45K22 PORTD.0 is SPI clock and PORTD.4 i SPI data out.

    What I must change in your TFT_demo code to adjust PIC pin to work with TFT display.
    Whether the pins of TFT displays D/C and RESET connected together on the same pin of the PIC processors or not.

    Code:
    ;----GLOBAL----HW---------   
        SSP_IF VAR PIR3.7
        tft_dc_bit con  32     ;5
        tft_cs_bit con 16   ;4 
        tft_rst_bit con 128   ;7
        tft_port var lath 
      
      
      
    
        INCLUDE "glcd_chr.pbpmod"        ;glcdc
        include "tft-ILI9431.bas" 
    ;    include "tft-ST7735.bas"
        INCLUDE "DT_INTS-18.bas"
        INCLUDE "ReEnterPBP-18.bas"
        INCLUDE "Elapsed_INT-18.bas"
        INCLUDE "font7x8.bas"
        
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,           Type,   ResetFlag?
            INT_Handler   TMR1_INT,   _ClockCount,   PBP,  yes
        endm
        INT_CREATE
    
     
    ENDASM  
    @ INT_ENABLE  TMR1_INT 
      
       
     
     
     
    
    
      
      define OSC 48
     
    '   osccon=$70   '64 mhz
       OSCTUNE.6=1 
       trisb.7=0
       trish=0        ' each pin on d has a led  for debug
       trisd.6=0     ;sck
       trisd.4=0      ;sdo
      
        BOXX VAR  BYTE
        BOXY VAR  BYTE
        BOXZ VAR  BYTE
        disp var byte
        tmp var word
        buff var byte[32]
       SSP2CON1=$20  ;$20 works too
       SSP2STAT=$40
       
       ;led var latd.7
      latb.7=1
     
      ;led=1
      gosub tft_init
    
     Serout2 PORTb.7,84,["ready ",#latd, 13,10]
     glcdc  font7x8       ;SET FONT


    is this OK?

    [CODE];----GLOBAL----HW---------
    SSP_IF VAR PIR3.7 'I don't understand what it mean

    symbol tft_dc_bit = PORTB.5
    symbol tft_cs_bit = PORTB.4
    symbol tft_rst_bit = PORTB.7

    tft_port var PORTB

    SDi from display I connect to PORD.4 and SCK from display I connect to PORTD.0 on PIC processor

  40. #40
    Join Date
    May 2013
    Location
    australia
    Posts
    2,512


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    SSP_IF VAR PIR3.7 'I don't understand what it mean
    THE SSP_IF VAR IS an alias to the SSP Interrupt Flag where PIR3.7 is the SSP2IF if you use ssp1 then use PIR1.3 for your chip



    symbol tft_dc_bit = PORTB.5
    symbol tft_cs_bit = PORTB.4
    symbol tft_rst_bit = PORTB.7
    you are asking for rmw trouble by using portb use latb instead
    Code:
    symbol tft_dc_bit = latb.5       >>with  matching  constant     tft_dc_bit  con  32     ie 2^5
    symbol tft_cs_bit = latb.4                        "              "            tft_cs_bit  con  16     ie 2^4
    symbol tft_rst_bit = latb.7                       "              "            tft_rst_bit con 128     ie 2^7
    tft_port var  latb
    SDi from display I connect to PORD.4 and SCK from display I connect to PORTD.0 on PIC processor
    correct for a PIC18F45K22 PORTD.4 is SDO2 and connects to display sdi
    and PORTD.0 is SCK2 and connects to display sck
    Last edited by richard; - 28th June 2015 at 05:50. Reason: IS JUST IMPOSSIBLE TO GET THE WHITE SPACE CORRECT

Similar Threads

  1. Replies: 0
    Last Post: - 25th September 2013, 19:33
  2. code examples / libraries for ILI9320 2.8" TFT LCD Module
    By longpole001 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th June 2013, 09:50
  3. I really need some help with PBP3
    By Ramius in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th February 2012, 17:05
  4. What's with PBP3?
    By BrianT in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th August 2011, 18:09
  5. Experience of driving TFT screens?
    By isaac in forum General
    Replies: 1
    Last Post: - 26th September 2008, 01:15

Members who have read this thread : 3

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts