News:

Let's find out together what makes a PIC Tick!

Main Menu

ILI9341 Flosi and Les code

Started by John Drew, Jun 21, 2021, 06:29 AM

Previous topic - Next topic

John Drew

This ILI9341 code was developed by Flosi and Les.
My working BAS is included so with a 18F25K22 and  suitably hooked up 2.8" ILI9341 SPI LCD should work as a test bench for you.
John

ILI9341 program.zip

Giuseppe

Thanks for sharing the code. Always comes in handy to someone

See_Mos

#2
I fired up my ILI9341 and 18F25k22 using the same HEX code that I used back in January but just got a blank screen.  I was powering the setup from Pickit+ at 5 volts.  A 'scope check showed that pin 7 of the display, SCK, did not look right, most of the time the pin was sitting at 4 volts but the clock pulses were only swinging from 0 to about 2.2 volts

I turned the supply off and reset the supply voltage to 3V3 and the display worked as expected.

I have now tried various simple level shifting.  A 1K resistor in series with each of the five signal leads allowed the display to work, potential dividers were less good, as was reversed diodes across the 1K resistors.  All three methods caused ringing or poor rise and fall times.   A 3v3 regulator and series resistors might work but I suspect distorted drive will still be a problem.

Stephen Moss

Quote from: See_Mos on Jul 19, 2021, 04:46 PMI have now tried various simple level shifting.  A 1K resistor in series with each of the five signal leads allowed the display to work, potential dividers were less good, as was reversed diodes across the 1K resistors.  All three methods caused ringing or poor rise and fall times.   A 3v3 regulator and series resistors might work but I suspect distorted drive will still be a problem.
It was not for a display but I once had a project where I needed to interface a 3.3V PIC to something with a 5V input/output. I used a 3.3V regulator and some ZVN4306A FETs and some pull up resistor (I think 4K7), the FET is designed for logic control and so basically turns hard on when Vgs rises to 2.5V or higher and I connected it as follows...
Gate to the 5V supply.
Drain to the applicable input pin (a pull-up resistor to the appropriate 3.3V or 5V supply voltage may be required if not built into the input pin).
Source to the applicable output pin (maintains signal phasing).

When the output signal goes high, Vgs falls below 2.5V turning the FET off and the input pin connected to the Drain is pulled high via the resistor.
When the output signal goes low, Vgs exceeds 2.5V turning the FET on and the input pin connected the the Drain is pulled to GND via the FET and PIC's I/O pin with the supply voltage dropped across the pull-up resistor.

As I recall that worked for both 3.3 to 5V and 5 to 3.3V translation, maybe it will work for you situation.

towlerg

"I was powering the setup from Pickit+ at 5 volts." Can't say that was a problem but I've been bitten twice (embarrassingly) using a PicKit2 as a power supply. Its a great programmer and a rubbish power supply.

tumbleweed

it's only spec'd to supply about 35mA or so.

flosigud

If you run both PIC and display at 3.3V there is no need for level shifting. The 5V to 3.3V regulator is optional but convenient. It can  be bypassed but if you don't and feed it with 3.3v the voltage drop is only .3V and the display is quite happy.

See_Mos

I thought I would revisit my ILI9341 display.

While the code "ILI9341 Randon.bas" still works I cannot get John's menu to display anything.  A 'scope check shows that all PORTC pins are staying as input?

I don't have a touch screen so I commented out all of the associated lines but still the same.

I looked through the .BAS and .inc files.  The port assignments are the same for both codes and I can see where PORTC is set to output but nowhere where it might be set back to input.

Any ideas please?

Using 18F25K22 and compiler V4.0.0.9

Pepe

I add fuses and proteus simulation

Giuseppe MPO

Device 18F25K22
    Declare Xtal 64
    Symbol PLLEN = OSCTUNE.6               ' PLL enable
    Symbol PLLRDY = OSCCON2.7            ' PLL run status
    PLLEN = 1                                             ' Enable PLL 4x 20MHz = 80Mhz
    While PLLRDY = 0 : Wend                     ' Wait until PLL is stable


I see that the PIC18F25K22 oscillator is set to 20MHz and then with the PLL x4 to 80MHZ.
On the datasheet the oscillator can be set to 16MHz max, is it an error or is it something that escapes me?

John Drew

I thought the maximum internal oscillator if the PLL was used was 16 MHz. To give 64 MHz.
A 20MHz crystal works with the 4 PLL to give 80MHz.
John

flosigud

I sometimes overclock 18f26k22 to 80MHz by using 20MHz christal. Settings must reflect what you use in your circuit.

Giuseppe MPO

I had never thought of overclocking the PIC, reading this post I was curious and I wanted to try. I checked with a small test program, also by switching an output pin and checking for correctness with the oscilloscope. I ran all my tests on a PIC18F25K22 and to my surprise I saw that the overclocked PIC performs very well, well above what I expected. The PIC worked correctly up to 33.3MHz (x4 = 133MHz), however this was the maximum limit, already at 34MHz it starts to give some problems. I think working at 32MHz (x4 = 128MHz) can work well. I also checked the absorption, at 64MHz it absorbs 19mA, at 128MHz it absorbs 30mA. Obviously this was just my curiosity, in case it should be tested in a much more thorough way.

See_Mos

I have been away for a few days and will come back to this problem later.

With regards to the device setup I replaced the setup lines with one of my own inc files which have the register names and character LCD setup already done. for the 18F25K22 I can chose 4, 8, 16 or 64mHz.

$define _LCD_PORT_ 0                    ' LCD PortA = 0, PortB = 1, PortC = 2
                                        ' 3 = custom or no LCD
Include "18F25K22 IntOsc 4.inc"         ' setup LCD etc.
'Include "18F25K22 IntOsc 8.inc"
'Include "18F25K22 IntOsc 16.inc"
'Include "18F25K22 Intosc 64.inc"

See_Mos

Of the several projects contributed by forum members it is now only Keypad.bas from post #1 that does not work.

It is the only one that uses Amicus18_spi2.inc.  The SPI inc's have caused me problems in the past and I have resorted to using alternative methods.

With several working programs to play with I no longer need keypad.bas but I may come back to the problem some time in the future.

John Drew

That's a good find See_Mos.
Because my final code also used a 18f25K22 I didn't pick up the problem with the SPI setup. It would be good to get to the bottom of the issue. A job for a "Round Tuit".
For our non English speaking friends "Tuit" are mythical beasts referred to in sentences such as "I must around to it sometime".
I have a shed full of "Tuits" :)
John

John Lawton

Hi John,

at least you got round to building a shed for them.

John

John Drew

#17
Quote from: 8100xt2 on Jan 11, 2022, 10:49 PMLooking for some bigger fonts  ;D is there a way to generate/make them ?

Marco
Hi Marco,
Your question had me intrigued. I went looking and found an excellent tutorial. How you use this information with Proton is however a mystery. There used to be information on the old forum. Maybe this is a starting point.
Just searched on Google for "Fonts ILI9341" and the Youtube video is very good. He demonstrates with large curly fonts.
ILI9341 TFT "write number function"
I tried to attach the URL but was unsuccessful.
John

Here's a site that uses a program called Font Converter. There may be people on this forum who will remember it and may have comments.
https://320volt.com/en/protonda-glcdye-giris-grafik-lcd-uygulamalari/

flosigud

Microchip has a program to generate fonts from Windows fonts. It is called Graphics Resource Converter. You have to translate some C to Basic. You can look at my fonts to see what you have to do.

Dompie

In the SSD1306 library in the download area is the Proton Fontconverter.exe from Les. With this you can translate Windows fonts to Positron.

Johan