There is no need to create another library for SPI, it is just about those few procedures that I have clearly written a few posts before and I can modify for another compiler on demand. It is simple for a user to include these in the code and use current library for ILI9341.
Maybe ME has a lot of other problems to solve and this is just not top priority. But I am here to help on this and once I write examples for all compilers everybody has solution. Just say what compiler/chip you are using and I try to help
SPI support for ILI9341
- nadir.celebic
- mikroElektronika team
- Posts: 465
- Joined: 15 Jun 2016 13:19
Re: SPI support for ILI9341
Hi,
Thanks @rares.porutiu
Unfortunately, at this moment we don't support SPI mode for ILI9341.
But our user @rares.porutiu wrote the code for SPI mode for ILI9341 on LibStock, maybe this will serve the purpose:
http://libstock.mikroe.com/projects/vie ... ft-library
Regards,
Nadir
Thanks @rares.porutiu
Unfortunately, at this moment we don't support SPI mode for ILI9341.
But our user @rares.porutiu wrote the code for SPI mode for ILI9341 on LibStock, maybe this will serve the purpose:
http://libstock.mikroe.com/projects/vie ... ft-library
Regards,
Nadir
-
- Posts: 54
- Joined: 20 Oct 2014 12:33
Re: SPI support for ILI9341
Hi,
Thank you for help. I use MikroC pro for PIC. The PIC that I use is 18F24K22 but I'll buy another if necessary.
BR
Thank you for help. I use MikroC pro for PIC. The PIC that I use is 18F24K22 but I'll buy another if necessary.
BR
-
- Posts: 28
- Joined: 18 Apr 2012 16:42
Re: SPI support for ILI9341
I will work on it, my hardware setup is with PIC18F97J60 and Mikropascal PIC and it works with that, I just have to write a HEX compiled with C for PIC to test. I will come back with the result as soon as I find a little time.
-
- Posts: 28
- Joined: 18 Apr 2012 16:42
Re: SPI support for ILI9341
I made it work, I am now curious how it will work on your chip. You have the modification to the library file and the whole main project file, put your own pins in the variable definitions. Good luck !
_Lib_TFT_Defs.c , in corresponding USES directory of your chip
first line is there, at the top, left for orientation on where to insert the rest :
#define TFT_Write_Strobe() TFT_WR = 0; asm nop; TFT_WR = 1;
//******************** ILI9341SPI BEGIN ****************************************
//forward declarations
void TFT_Init_ILI9341_8bit_Custom_SPI(unsigned int display_width, unsigned int display_height, unsigned long _Set_Index_SPI, unsigned long _Write_Command_SPI, unsigned long _Write_Data_SPI);
static void TFT_Reset_ILI9341();
static void TFT_Set_Address_ILI9481(unsigned int x, unsigned int y);
//replacement routine for init ILI9341SPI, needs the 3 function addresses
void TFT_Init_ILI9341_8bit_Custom_SPI(unsigned int display_width, unsigned int display_height, unsigned long _Set_Index_SPI, unsigned long _Write_Command_SPI, unsigned long _Write_Data_SPI ) {
if (Is_TFT_Set() != 1) {
//************* Here set to SPI instead of parallel ***********************
TFT_Set_Index_Ptr = _Set_Index_SPI;
TFT_Write_Command_Ptr = _Write_Command_SPI;
TFT_Write_Data_Ptr = _Write_Data_SPI;
//*************************************************************************
}
TFT_DISP_WIDTH = display_width;
TFT_DISP_HEIGHT = display_height;
if (display_width >= display_height)
TFT_Disp_Rotation = 0;
else
TFT_Disp_Rotation = 90;
TFT_Set_Pen(CL_BLACK, 1);
TFT_Set_Brush(0, 0, 0, 0, 0, 0);
TFT_Move_Cursor(0, 0);
ExternalFontSet = 0;
// Reset device
TFT_Reset_ILI9341();
TFT_Set_Address_Ptr = TFT_Set_Address_ILI9481;
}
//******************** ILI9341SPI END ******************************************
TFTSPI.c :
// TFT display connections
//FAKES ! Needed since they are requested as externals in the TFT library, not used in SPI mode
char TFT_DataPort at LATC;
sbit TFT_WR at TFT_DataPort.B0;
sbit TFT_RD at TFT_DataPort.B1;
char TFT_DataPort_Direction at TRISC;
sbit TFT_WR_Direction at TFT_DataPort_Direction.B0;
sbit TFT_RD_Direction at TFT_DataPort_Direction.B1;
//Reals
//Use 3V3 processor voltage, it may not work if the lines provide 5V !!!
sbit TFT_CS at LATC.B2;
sbit TFT_CS_Direction at TRISC.B2;
sbit TFT_RS at LATG.B3;
sbit TFT_RS_Direction at TRISG.B3;
sbit TFT_RST at LATB.B5;
sbit TFT_RST_Direction at TRISB.B5;
// My board has TFT LIGHT Control
sbit TFT_LIGHT at LATB.B1;
sbit TFT_LIGHT_Direction at TRISB.B1;
//TFT Light control is INVERTED, can be used as PWN also to dimm the light
const TFT_LIGHT_ON=0;
// End of TFT display connections
//************************** TFT SPI ROUTINES **********************************
//Here replace with your own SPI READ syntax, USE READ because Write may not work !
// I put theese functions in USER code, not in the TFT LIB modifications,
// since you may change SPI number without changing the lib
void TFT_Set_Index_SPI(unsigned short index) {
TFT_RS = 0;
SPI1_READ(index);
TFT_RS = 1;
}
void TFT_Write_Command_SPI(unsigned short cmd) {
TFT_RS = 1;
SPI1_READ(cmd);
}
void TFT_Write_Data_SPI(unsigned int _data) {
SPI1_READ((_data >> );
SPI1_READ((_data));
}
//******************************************************************************
void main() {
// This is for my board
// This control is on my board , but you should have a circuit on any board to Power the bright LED's of the 9341 board
TFT_Light_Direction=0;
TFT_Light=TFT_Light_ON;
//Initialize this first
UART1_Init(115200);
//Initialize the SPI used for the TFT
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
//Set the rotation before INIT
TFT_Rotate_180(0);//has to be set before TFT_Init
// Initialize TFT display
TFT_Init_ILI9341_8bit_Custom_SPI(320,240,&TFT_Set_Index_SPI,&TFT_Write_Command_SPI,&TFT_Write_Data_SPI);
TFT_Fill_Screen(cl_Blue);//simple fill test
TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL);
TFT_Write_Text("TFT SPI LIBRARY DEMO, WELCOME !", 0, 0);//Test the TEXT routines
//this loop is to test that processor is not frozen, echoes the keys, also RESETS at the character *, like I reset for bootloader
while (1) {
if (UART1_Data_Ready() ==1){
char receive = UART1_Read();
if (receive =='*'){
while (1); //just don't go further
}
UART1_Write(receive);
}
asm {clrwdt} //If you have activated watchdog, prevent from (WD)RESET while the loop loops
}
}
_Lib_TFT_Defs.c , in corresponding USES directory of your chip
first line is there, at the top, left for orientation on where to insert the rest :
#define TFT_Write_Strobe() TFT_WR = 0; asm nop; TFT_WR = 1;
//******************** ILI9341SPI BEGIN ****************************************
//forward declarations
void TFT_Init_ILI9341_8bit_Custom_SPI(unsigned int display_width, unsigned int display_height, unsigned long _Set_Index_SPI, unsigned long _Write_Command_SPI, unsigned long _Write_Data_SPI);
static void TFT_Reset_ILI9341();
static void TFT_Set_Address_ILI9481(unsigned int x, unsigned int y);
//replacement routine for init ILI9341SPI, needs the 3 function addresses
void TFT_Init_ILI9341_8bit_Custom_SPI(unsigned int display_width, unsigned int display_height, unsigned long _Set_Index_SPI, unsigned long _Write_Command_SPI, unsigned long _Write_Data_SPI ) {
if (Is_TFT_Set() != 1) {
//************* Here set to SPI instead of parallel ***********************
TFT_Set_Index_Ptr = _Set_Index_SPI;
TFT_Write_Command_Ptr = _Write_Command_SPI;
TFT_Write_Data_Ptr = _Write_Data_SPI;
//*************************************************************************
}
TFT_DISP_WIDTH = display_width;
TFT_DISP_HEIGHT = display_height;
if (display_width >= display_height)
TFT_Disp_Rotation = 0;
else
TFT_Disp_Rotation = 90;
TFT_Set_Pen(CL_BLACK, 1);
TFT_Set_Brush(0, 0, 0, 0, 0, 0);
TFT_Move_Cursor(0, 0);
ExternalFontSet = 0;
// Reset device
TFT_Reset_ILI9341();
TFT_Set_Address_Ptr = TFT_Set_Address_ILI9481;
}
//******************** ILI9341SPI END ******************************************
TFTSPI.c :
// TFT display connections
//FAKES ! Needed since they are requested as externals in the TFT library, not used in SPI mode
char TFT_DataPort at LATC;
sbit TFT_WR at TFT_DataPort.B0;
sbit TFT_RD at TFT_DataPort.B1;
char TFT_DataPort_Direction at TRISC;
sbit TFT_WR_Direction at TFT_DataPort_Direction.B0;
sbit TFT_RD_Direction at TFT_DataPort_Direction.B1;
//Reals
//Use 3V3 processor voltage, it may not work if the lines provide 5V !!!
sbit TFT_CS at LATC.B2;
sbit TFT_CS_Direction at TRISC.B2;
sbit TFT_RS at LATG.B3;
sbit TFT_RS_Direction at TRISG.B3;
sbit TFT_RST at LATB.B5;
sbit TFT_RST_Direction at TRISB.B5;
// My board has TFT LIGHT Control
sbit TFT_LIGHT at LATB.B1;
sbit TFT_LIGHT_Direction at TRISB.B1;
//TFT Light control is INVERTED, can be used as PWN also to dimm the light
const TFT_LIGHT_ON=0;
// End of TFT display connections
//************************** TFT SPI ROUTINES **********************************
//Here replace with your own SPI READ syntax, USE READ because Write may not work !
// I put theese functions in USER code, not in the TFT LIB modifications,
// since you may change SPI number without changing the lib
void TFT_Set_Index_SPI(unsigned short index) {
TFT_RS = 0;
SPI1_READ(index);
TFT_RS = 1;
}
void TFT_Write_Command_SPI(unsigned short cmd) {
TFT_RS = 1;
SPI1_READ(cmd);
}
void TFT_Write_Data_SPI(unsigned int _data) {
SPI1_READ((_data >> );
SPI1_READ((_data));
}
//******************************************************************************
void main() {
// This is for my board
// This control is on my board , but you should have a circuit on any board to Power the bright LED's of the 9341 board
TFT_Light_Direction=0;
TFT_Light=TFT_Light_ON;
//Initialize this first
UART1_Init(115200);
//Initialize the SPI used for the TFT
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
//Set the rotation before INIT
TFT_Rotate_180(0);//has to be set before TFT_Init
// Initialize TFT display
TFT_Init_ILI9341_8bit_Custom_SPI(320,240,&TFT_Set_Index_SPI,&TFT_Write_Command_SPI,&TFT_Write_Data_SPI);
TFT_Fill_Screen(cl_Blue);//simple fill test
TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL);
TFT_Write_Text("TFT SPI LIBRARY DEMO, WELCOME !", 0, 0);//Test the TEXT routines
//this loop is to test that processor is not frozen, echoes the keys, also RESETS at the character *, like I reset for bootloader
while (1) {
if (UART1_Data_Ready() ==1){
char receive = UART1_Read();
if (receive =='*'){
while (1); //just don't go further
}
UART1_Write(receive);
}
asm {clrwdt} //If you have activated watchdog, prevent from (WD)RESET while the loop loops
}
}
-
- Posts: 54
- Joined: 20 Oct 2014 12:33
Re: SPI support for ILI9341
@rares.porutiu thank you for your time.
I will try this on mine chip and let you know the results.
BR
I will try this on mine chip and let you know the results.
BR
-
- Posts: 54
- Joined: 20 Oct 2014 12:33
Re: SPI support for ILI9341
@rares.porutiu
Can you please send whole project in zip file?
Thank you.
Can you please send whole project in zip file?
Thank you.
Re: SPI support for ILI9341
Hi, Pascal and C are not my thing. Can you write an example in Basic for 18F45K22 ? If i get that working i hopefully can convert it for other micro's, like PIC32mx534 (mini-32)rares.porutiu wrote:But I am here to help on this and once I write examples for all compilers everybody has solution. Just say what compiler/chip you are using and I try to help
-
- Posts: 46
- Joined: 16 Apr 2011 14:37
Re: SPI support for ILI9341
I want to know, if there is any support coming for SPI library for ILI9341 TFT in near future??
If yes then please post.
I am already planning to use the following library.
https://libstock.mikroe.com/projects/vi ... ft-library
So please don't suggest this, I am aware of this one.
Thanks
If yes then please post.
I am already planning to use the following library.
https://libstock.mikroe.com/projects/vi ... ft-library
So please don't suggest this, I am aware of this one.
Thanks
Re: SPI support for ILI9341
he ILI9341 driver is included in the compiler's library and supported by the Visual TFT.
Re: SPI support for ILI9341
Hi,
Only parallel communication is supported by the library.
Regards,
Filip.
Only parallel communication is supported by the library.
Regards,
Filip.