Hello All-
I have been trying to use an ILI9341 with software serial on a PIC18F67K40 and I have been told the include file does work for both hardware and software SPI uses.
I have looked at glcd.h and glcd_ili9341.h and do see where it looks like it will work, rather clever way to determine hardware of software use by using the 'DC' bit.
I have searched for 'ILI9341 and software SPI' but did not see anyone using it.
I have attached a logic analyzer which shows:
Grey Trace is Data In
Orange Trace is Clock
Red Trace is Chip Select - active low
Orange Trace is Command
The things I noticed are the clock trace does not seem to clock all the time as it should. It is shared with another SPI device and it works fine, although different Chip Selects.
The Data trace also looks weird and it is also shared with another SPI device and it works fine, although different Chip Selects.
The Command trace should be going up and down? but it seems to be low all the time which means if it is used, is always in Command Mode.
I have explicitly set GLCD_DC, GLCD_CS, GLCD_RESET (which I hold HIGH), GLCD_DI, and GLCD_DO.
Also set the DIR for all the ports.
I have also tried switching the GLCD_DI and GLCD_DO in case I misunderstood the datasheet for the ILI9341 to no avail. I have asked another user who bought this GLCD from Amazon if it was only 3.3 or 5v and he said he has used it with both voltage levels so I think the interface levels currently at 5v should be fine. The J1 jumper is NOT shorted.
The software ports do only seem to 'wiggle' when the GLCD is being 'told' to do something so it seems the ports are correct.
Wondering if anyone else has used software SPI on this or any other GLCD.
Compiler does not throw any errors at all.
This is a specific 18F ILI9341 implementation using software SPI. The hardware SPI is not enabled therefore PPS is not set and the ILI9341 uses the ILI93141 software SPI methods.
The basic program is
#INCLUDE<glcd.h>
#DEFINEGLCD_TYPEGLCD_TYPE_ILI9341'Pin mappings for ILI9341 can be any output port when not using PPS#DEFINE GLCD_DC porta.1#DEFINE GLCD_CS porta.2#DEFINE GLCD_RESET porta.3#DEFINE GLCD_DO portc.5#DEFINE GLCD_SCK portc.3GLCDCLSGLCDPrint 0,0, "hello world"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That did not work.
Going to see if I have a simpler board on which to try.
May have a Clicker board from Mikro. If not, I will look for something simple.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This worked. I connected the K40 and the ILI9341. Worked first attempt.
So, may advice.
Check the chip to GLCD connection by adding a Do: GLCD_DC=!GLCD_DC:Loopwhere you test each port assignment in turn. Do not add port output control because you will be using the port output control from the GLCD library. Here... I had the GLCD_DO on the incorrect port and this test helped me relocate the connection to the GLCD.
Check the operating voltage of the ILI9341. I have many of them. Each one here is marked with its operating voltage tolerance. They range from 3v3 to 5v0. But, most will not operate above 4v0 - so, set the operating voltage of the whole circuit to 3v3. This is the general issue with these GLCDs... the operating specifications are not consistent.
#CHIP18F67K40
#INCLUDE<glcd.h>
#DEFINEGLCD_TYPEGLCD_TYPE_ILI9341'Pin mappings for ILI9341 can be any output port when not using PPS#DEFINE GLCD_DC porta.1#DEFINE GLCD_CS porta.2#DEFINE GLCD_RESET porta.3#DEFINE GLCD_DO portc.5#DEFINE GLCD_SCK portc.3 GLCDCLS GLCDPrint 0,0, "hello world"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
OK Group, I have found a simple little board on which to try this GLCD library.
It is a MikroElectronica Click 2 PIC18FX which uses a PIC18F67K40.
I am using the MikroBootLoader to get the test code into the proc.
I have never used this bootloader but the doc says just hit RESET after the upload and it will start with my code.
It is a blank screen.
The LCD is powered by 3.3v and VCC is also 3.3v I have tried both of these at 5v but no difference.
Screen seems to roll up from the bottom but no text is displayed.
Code is attached for help.
I cannot review the code on my phone. But, if try clearing the screen to another color. glcdcls tft_blue or some other color. If this works then you know the communications are working.
Try it, let me know results.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey Hey Hey!
It is working.
Curious why the DIRs and do understand the RESET directive.
Wll copy and paste in original learning code for verification.
Nice to know I can use a Mikroe Click board for development with GCB!
Thanks again Evan for shedding light.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello All-
I have been trying to use an ILI9341 with software serial on a PIC18F67K40 and I have been told the include file does work for both hardware and software SPI uses.
I have looked at glcd.h and glcd_ili9341.h and do see where it looks like it will work, rather clever way to determine hardware of software use by using the 'DC' bit.
I have searched for 'ILI9341 and software SPI' but did not see anyone using it.
I have attached a logic analyzer which shows:
Grey Trace is Data In
Orange Trace is Clock
Red Trace is Chip Select - active low
Orange Trace is Command
The things I noticed are the clock trace does not seem to clock all the time as it should. It is shared with another SPI device and it works fine, although different Chip Selects.
The Data trace also looks weird and it is also shared with another SPI device and it works fine, although different Chip Selects.
The Command trace should be going up and down? but it seems to be low all the time which means if it is used, is always in Command Mode.
I have explicitly set GLCD_DC, GLCD_CS, GLCD_RESET (which I hold HIGH), GLCD_DI, and GLCD_DO.
Also set the DIR for all the ports.
I have also tried switching the GLCD_DI and GLCD_DO in case I misunderstood the datasheet for the ILI9341 to no avail. I have asked another user who bought this GLCD from Amazon if it was only 3.3 or 5v and he said he has used it with both voltage levels so I think the interface levels currently at 5v should be fine. The J1 jumper is NOT shorted.
The software ports do only seem to 'wiggle' when the GLCD is being 'told' to do something so it seems the ports are correct.
Wondering if anyone else has used software SPI on this or any other GLCD.
Compiler does not throw any errors at all.
Lots of demos show how to use the ILI9341.
See https://github.com/GreatCowBASIC/Demonstration_Sources/blob/main/Vendor_Boards/Great_Cow_Basic_Demo_Board/18f27Q84_chiprange_demonstrations/260_spi_glcd_using_ili9341.gcb
This is a specific 18F ILI9341 implementation using software SPI. The hardware SPI is not enabled therefore PPS is not set and the ILI9341 uses the ILI93141 software SPI methods.
The basic program is
Thanks Evan, I have perused the demos as well.
Will make this simple test and see what happens.
Thanks.
That did not work.
Going to see if I have a simpler board on which to try.
May have a Clicker board from Mikro. If not, I will look for something simple.
Thanks.
Want me to try here?
Can if you would like - still lookin' around to see what I may have around the lab.....
This worked. I connected the K40 and the ILI9341. Worked first attempt.
So, may advice.
Do: GLCD_DC=!GLCD_DC:Loop
where you test each port assignment in turn. Do not add port output control because you will be using the port output control from the GLCD library. Here... I had the GLCD_DO on the incorrect port and this test helped me relocate the connection to the GLCD.OK Group, I have found a simple little board on which to try this GLCD library.
It is a MikroElectronica Click 2 PIC18FX which uses a PIC18F67K40.
I am using the MikroBootLoader to get the test code into the proc.
I have never used this bootloader but the doc says just hit RESET after the upload and it will start with my code.
It is a blank screen.
The LCD is powered by 3.3v and VCC is also 3.3v I have tried both of these at 5v but no difference.
Screen seems to roll up from the bottom but no text is displayed.
Code is attached for help.
I cannot review the code on my phone. But, if try clearing the screen to another color.
glcdcls tft_blue
or some other color. If this works then you know the communications are working.Try it, let me know results.
No joy here at the moment Evan. After reset screen rolls from the bottom and back to white or a whitish grey.
Will keep after it......
The program. Remove the DIR and those RESETs. Those resets
would mess up all the initialisation completed by the library.
Edit and test.
Hey Hey Hey!
It is working.
Curious why the DIRs and do understand the RESET directive.
Wll copy and paste in original learning code for verification.
Nice to know I can use a Mikroe Click board for development with GCB!
Thanks again Evan for shedding light.
The DIR would not cause an issue, but, the RESET would have been the issue.
The GLCD init is:
So, the RESET would have needed all the INIT commands, again.
If a RESET is required, sometimes I reset a GLCD to ensure the state is known, then I would call
InitGLCD
to correctly reset and init the GLCD.Insight
To figure out what happens when you call
InitGLCD
can be determined by looking at the program specific CDF file.Searching the CDF for INITGLCD shows the following:
So,
InitGLCD
actually is defined asInitGLCD_ILI9341
. So, the call toInitGLCD
would actually callInitGLCD_ILI9341
There is a (long) script in GLCD.H that sets up many Public methods to the specific GLCD.
Last edit: Anobium 2023-09-20