1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

LCD SPI projects.

Discussion in 'Oshonsoft' started by camerart, Oct 15, 2017.

  1. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    Cleared all the ILI9225 out of the Arduino IDE, there seems to be a problem with the original ILE9225 download from git hub.????
    Downloaded the Arduino version, at first it was very poor quality pixel output.

    Changed program from hardware SPI, to software option, now running OK.

    E

    EDIT:
    Now have it running under hardware SPI, the 9225 is very edge sensitive.
    Added a 2k pull up to RS and about 3pF to RST it now gives a clean fast operation.[ all 3 modules]
    The software SPI is too slow IMO.
    Will experiment with a intermediate buffer IC.
     
    Last edited: Nov 1, 2017
  2. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,369
    Likes:
    11
    Location:
    Dorset UK.
    Hi,
    Here is a schematic of the latest 18LF4520 TEST PCB.
    As usual check for faults, please.
    EDIT: I've edited the 5110 out of the title.
    EDIT: I can change the 5110 to the present module, if wanted.
    C.
     

    Attached Files:

    Last edited: Nov 5, 2017
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi, Nigel Goodwin
    After a quite a few hours, with no success, trying to use Oshonsoft basic to drive the Hiletgo 2.2inch SPI TFT LCD, I decide to retry the 3 off, Arduino UNO with the 3 off, TFT LCD modules.
    All the SPI and control signals were monitored on a scope and appeared OK

    When using the Arduino program hardware version of the SPI, the LCD's would work intermittently, with very poor quality or sometimes not at all, when the module was subject to even a small rise in ambient temperature, but worked OK with the software SPI, but slooow.

    Do you have any information regarding the work you have done when using these TFT's, with hardware/software SPI.?

    I am wondering as the price per module was lower than expected, that I have bought some production rejects.

    Eric
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,251
    Likes:
    911
    Location:
    Rochdale UK

    Sounds like the clock polarity is wrong... These module clock on the rising edge The ILI9225 has a High polarity and the ILI9341 has a Low polarity... The Hiletgo 2.2inch can have the latter chip in!!
     
    • Informative Informative x 1
  6. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,295
    Likes:
    647
    Location:
    Derbyshire, UK
    Hi Eric,

    Mine haven't come yet, although I have received a couple of similar sized 240x320 modules I ordered at the same time, these use the ILI9341 and I simply plugged them in, in place of the larger ones I already have, and they worked with no changes.

    As soon as they turn up I'll give them a try, although I'll obviously have to port the code to PIC to test them with a PIC.
     
    • Thanks Thanks x 1
  7. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,295
    Likes:
    647
    Location:
    Derbyshire, UK
    OK, mine arrived today - just tried them both (I ordered two), first with software SPI - so the module plugs directly in the Arduino, but you have to alter the pins used in the driver demo. I then removed the display and wired it to the hardware SPI, both worked fine again?.

    Obviously if it works with software SPI, it 'should' work with hardware - unless it's set to the wrong mode, or it's running too fast.

    I'll get a board made for a PIC, and port the library for it.
     
    • Informative Informative x 1
  8. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,295
    Likes:
    647
    Location:
    Derbyshire, UK
    Works fine on my PIC24F here as well, on both software and hardware SPI - I'm feeding it with 3.3V supply and signals, and it's fine at that.

    If anyone is interested in some even cheaper LCD's?, I've ordered a couple of these:

    https://www.aliexpress.com/item/2-0...ouch-Pen-R179T-Drop-Shipping/32780151979.html

    Slightly smaller at 2 inch, and not 5V tolerant, but does come with a touch screen as well - and at a silly price. They also use the ST7775, which I prefer to the ILI9225 - which doesn't seem to provide screen rotation, and has to be done rather crudely.
     
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Nigel,
    Book marked your ali link, I will order a couple of modules.

    The 3, ili9225 2.2" TFT LCD modules I have, are still giving intermittent operation.
    Checked the onboard 3Vreg its OK, the onboard HC245 level shifter should be OK for 5V signal to 3V conversion input to the 9225 IC.

    The sort of mis-operation I get with S/W and H/W SPI are:
    Works OK 'sometimes' when powered On, runs the Arduino UNO demo OK, other times no operation or corrupted display.
    Pinching a connecting wire between finger and thumb can cause display corruption.
    Connecting wires from UNO to LCD are approx 3" long.

    Having the module powered from the USB or a external 9Vdc PSU or both, gives the same intermittent operation.
    Tried 3 Arduino UNO's , these UNO's work OK on other SPI projects.

    Noticed also that the LED back lights do not work.?
    Becoming convinced that I have three duff LCD modules.:banghead:

    Eric
     
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    Seeing that you used 3.3v, I decided to try resistive dividers 2k2/3k3 between the 5v powered UNO and 5v powered TFT, on all 5 signal lines.
    All three LCD modules now work OK, with HW and SW SPI.

    It looks as though the onboard HC245 level shifters are not working as expected, perhaps getting 'punch thru' of the 5v signal levels.

    Now its back to the 18F4520, added the resistive dividers to the development board.

    Eric
     
  11. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,295
    Likes:
    647
    Location:
    Derbyshire, UK
    I used it 'as is' on the Uno s0 5V, but of course the 24F chip is 3.3V so that's what it was fed from there, both power and signal.
     
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    Now have the 9225 LCD module working with Oshonsoft Basic, programmed into a 18F4520 PIC.
    Both the PIC and LCD are powered by 5v, series 2k2 resistors in series with the 5 signal lines, are required for stable operation of the LCD.

    The screen fill speed with colours is comparable with the Arduino in software SPI mode.

    The Oshonsoft SPI, as most users know, is software based, which is a pain.

    Next step is to tidy up the graphics then write text to the LCD.

    E
     
  13. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,251
    Likes:
    911
    Location:
    Rochdale UK
    Do you want me to write a hardware version??? It'll be quite simple...

    If you send me your init code and the graphics write it'll speed things up..
     
  14. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Ian,
    Thanks for the kind offer, I have more work to do on the 9225 Basic program development, ie the text routines.
    I have considered adding a SPI assembler block of code to the the final Basic program, so I may get back to you shortly.

    E
    Slowing down a little, now in my 86th solar cycle.!!!:woot:
     
  15. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,369
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    86 and as sharp as ever, well done.
    C.
     
  16. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    In the 86th Solar cycle means I am only 85!, at the end of this annual solar orbit I will be 86.

    Eric
     
  17. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,369
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    Ooops!
    I was going to make a joke, asking if you still wear your solar flares, but thought better of it;)
    C
     
  18. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,251
    Likes:
    911
    Location:
    Rochdale UK
    I did a tiny hardware SPI function for Oshonsoft... I tested to 2mhz on a 25c320 SPI memory chip!!
    If used with your screens, it'll speed things up a tad!!
    Here is the code for a pic18f4620 running at 8Mhz internal clock..
    Code (basic):

    Define CONFIG1L = 0x00
    Define CONFIG1H = 0x08
    Define CONFIG2L = 0x1e
    Define CONFIG2H = 0x00
    Define CONFIG3L = 0x00
    Define CONFIG3H = 0x83
    Define CONFIG4L = 0x80
    Define CONFIG4H = 0x00
    Define CONFIG5L = 0x0f
    Define CONFIG5H = 0xc0
    Define CONFIG6L = 0x0f
    Define CONFIG6H = 0xe0
    Define CONFIG7L = 0x0f
    Define CONFIG7H = 0x40
    Symbol ss = LATC.2
    Dim x As Byte
    Dim ret As Byte
    OSCCON = 0x70
    ADCON1 = 0xf
    Call spi_init()
    TRISA.5 = 0
    LATA.5 = 0
    WaitMs 10
    For x = 0 To 32
     ss = 0
     ret = do_spi_8(6)
     ss = 1
     ss = 0
     ret = do_spi_8(2)
     ret = do_spi_8(0)
     ret = do_spi_8(x)
     ret = do_spi_8(32 - x)
     ss = 1
     WaitMs 10
    Next x
    LATA.5 = 1
    stop: Goto stop
    End  
    ----------------------------------------                                          
    Proc spi_init()
     TRISC.5 = 0
     TRISC.2 = 0
     TRISC.4 = 1
     TRISC.3 = 0
     ss = 1
     SSPSTAT = 0
     'SSPSTAT.CKE = 1  'clock edge un remark for trailing edge
     SSPCON1 = 0x20  'full whack... at 8mhz 2mhz operation no SS control
          '00 = fosc/4.. 01 = fosc /16
          '10 = fosc/64.. 11 contolled by timer2.
     'SSPCON1.CKP = 1 'clock polarity unremark for high polarity
    End Proc  
    -------------------------------------------                                      
    Function do_spi_8(data As Byte) As Byte
     do_spi_8 = SSPBUF
     SSPBUF = data
     While Not SSPSTAT.BF
     Wend
     WaitUs 10
    End Function
    -------------------------------------------------                                    
     
     
  19. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi Ian,
    Many thanks for that, have downloaded your program, it compiles OK, has to rem out the ----------------------- spacers.
    Trying it it out later.:)
    The simple LCD graph functions have been tested, reasonable.
    Started on the Basic for the writing text to display, the limitations of the Oshonsoft maths conditional statements means loads of work arounds, calling it a day, start fresh tomorrow.:banghead:

    Eric
     
  20. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,251
    Likes:
    911
    Location:
    Rochdale UK
    I am trying to do a linear buffer for oshonsoft.. I want a 1k buffer for screen double buffering..
    I only did that because copy and paste didn't!!! It looked awful without....
     
  21. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,220
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi I,
    I got some 18F4620 for SD card projects.

    E
    A01.gif
     

Share This Page