A tft addin for pbp3


Closed Thread
Results 1 to 40 of 142

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    I have a bit of conditional compiling going on to select mssp1 or mssp2 but is there a way to conditionally check if the pic18 chosen to compile for has 1,2 or no mssp modules .

    Code:
    #IFNDEF TFT_SPI
        #DEFINE TFT_SPI 1 
          ;DEFAULT
     #ENDIF   
    
    
    
     #IF   TFT_SPI = 1
         SSP1_IF VAR pir1.3    
     #ELSE
         SSP1_IF VAR PIR3.7
     #ENDIF
    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 )
        SSP1_IF = 0
        #IF   TFT_SPI = 1
        SSP1BUF = CMD 
        #else
        SSP2BUF = CMD 
        #endif
        WHILE   SSP1_IF =0 ' wait for SPI interupt flag
        wend
        tft_port = tft_port |   ( tft_dc_bit|  tft_cs_bit   )
        
    '@     movff  _p_int  , INTCON 
    return
    the problem is that if the pic has only one mssp then sspbuffer becomes sspbuf where as for two its ssp1buf or ssp2buf.
    and it would nice to have shiftout as an option.

    other than that it nearly a done deal

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Hi Richard,
    Apart from including a list of all PICs with two MSSP modules and checking against that list I don't know a way of telling at compile time. There's probably a way to have the assembler do it but then its too late.....

    However, looking at the P18F45K22.INC file, as an example, one can see that SSPBUF and SSP1BUF are both declared and pointing at the same adress so I think you should be safe using SSPBUF and SSP2BUF. Obviously one can't know if Microchip will continue to alias SSPBUF to SSP1BUF on devices with multiple MSSP modules...

    /Henrik.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    hi henrik

    in asm I can do this

    Code:
     asm
      ifdef SSPIF
         #define  ssp_1  0
        endif
    
    
        ifdef SSP1IF
         #define  ssp_1  1 
        endif
    
    endasm


    but a #define thats made here seems unreadable to the pbp compiler
    and I don't really want to do the whole routine in asm

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    tried using
    SSPBUF = CMD
    when ssp1buf exists and it syntax errors it really wants SSP1BUF = CMD

    tried
    sspbuf var ssp1buf

    result
    syntax error var is already an alias

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Hi Richard,
    Which device are you targeting?

    /Henrik.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    but a #define thats made here seems unreadable to the pbp compiler
    and I don't really want to do the whole routine in asm
    Exactly, that's what I meant by "but then it's too late". The assembler doesn't do its stuff until PBP is finished doing it stuff so whatever you do in and with the assembler is unkown to the compiler....

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Which device are you targeting?
    any pic18 was what I'm aiming at , hoping to get a default compile that would use mssp1 if it exists/shiftout if no mssp exits and mssp2 if user sets a define to do so.
    dare I say idiot proof , but I don't think I can do it , at this point users will need some knowledge of the pic hardware chosen for their application and will need to modify the code accordingly.

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Hi Richard,
    I tried the following very simple program
    Code:
    CMD VAR BYTE
    CMD = SSPBUF
    CMD = SSP1BUF
    CMD = SSP2BUF
    I compiled it for a couple of 18F devices, all with 2 MSSP modules. Some of them (like the 18F24J11, 18F44J50 and 18F46K22) worked fine while others didn't and gave a Bad Expression error on the CMD=SSPBUF. My conclusion is that Microchip isn't consistent in aliasing SSPBUF to SSP1BUF thru all their device header files :-(

    I don't know a way of doing it automatically - that's not to say it can't be done though!
    I'd probably use SSPBUF in the code and add a comment saying that if the compiler complains then add SSPBUF VAR SSP1BUF to the code. That's certainly not idiot proof but you do know that's an impossible thing to achieve ;-)

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    henrik
    I think your right and what you suggest may be as good as it gets


    add SSPBUF VAR SSP1BUF on Expression error

  10. #10
    Join Date
    Oct 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Is it possible that I destroy my TFT-display because my power supply for PIC18f4520 is 5volt?Communication between PIC and ILI9341 is on 5 volt.

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


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    these displays are 3.3v devices . the only pin that is different is the vcc pin that leads to a 3.3v ldo regulator . my displays function ok with vcc =3.3v . one has a jumper to bypass the regulator if desired but this has not been necessary .
    see schematic
    ps the schematic shows the mclr pullup resistor connected to gnd , this is wrong it should be vcc
    Attached Images Attached Images
    Last edited by richard; - 30th August 2015 at 23:25.

  12. #12
    Join Date
    Oct 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    OK,it works now.I replace a voltage regulator on EASYPIC 5 board from 5V to 3.3V and it works.
    What I need to do to send JPG picture to TFT display?

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


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    What I need to do to send JPG picture to TFT display?
    start about post#41 I have provided some python code to convert arduino c code files generated by the "UTFT ImageConverter565.exe PGM " TO a pbp compatible format.
    be aware that a 200x200 pixel image takes 80,000 bytes of flash memory. an external flash chip is more practical for this sort of thing , I have provided code to do that also

  14. #14
    Join Date
    Oct 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    I create a six buttons on LCD and one button must work like a push button.

    When I push the button, the LED which is connected to PORTD.0 must light all the time as the button is pressed.
    When I release the button LED must go off.

    Is it possible to create something like that?

  15. #15
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    done a bit more

    have added tft_sleep tft_wake tft_on tft_off subs, added DRAWRRECT usercmd (draw round cornered rectangle).
    change way buttons are defined . can have rectangular buttons , a button colour scheme and the button "title" text is now stored in pgm memory
    attached is a demo for a pic18f2520 using sleep/ wake on touch interrupt , backlight modulation using a pnp trany bc557 (full 10 bit)

    can supply cct if req
    Attached Files Attached Files

  16. #16
    Join Date
    Oct 2013
    Posts
    41


    Did you find this post helpful? Yes | No

    Default Re: A tft addin for pbp3

    Hello people
    if someone tried Richard's example with PIC18F2520 or PIC18f4520
    I tried his example with PIC18F4520 and unfortunately not working. I have just a white screen.
    If someone can send me a hex file or an example of code that works with the PIC18F4520 so that I know if my screen working properly or it is damaged.

    my connection from TFT to PIC
    tft_dc_bit con 8 ;ie bit 3 PORT B.3
    tft_cs_bit con 32 ;ie bit 5 PORTB.5
    tft_rst_bit con 16 ;ie bit 4 PORTB.4
    tft mosi PORTC.5
    tft sck PORTC.3



    when I change value of this variable the led intensity is change on port C.2 , so PIC is working
    cont=50 ;half brightness

Similar Threads

  1. Replies: 0
    Last Post: - 25th September 2013, 18: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, 08:50
  3. I really need some help with PBP3
    By Ramius in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th February 2012, 16:05
  4. What's with PBP3?
    By BrianT in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th August 2011, 17:09
  5. Experience of driving TFT screens?
    By isaac in forum General
    Replies: 1
    Last Post: - 26th September 2008, 00:15

Members who have read this thread : 0

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