Go Down

Topic: TFT shield (Read 338 times) previous topic - next topic

baijusuno

Hi,
     My new 2.4 inch TFT shield (MCUFriend.com) is working with my uno. Now i tried to connect it with PIC18F46k22 and tried to invert the display(color)  but nothing happened
the code is as below I connected it in 8 bit parallel mode. data port is portD. CS DC etc connected to portC
using MPLAB & XC8 will anybody be able to help me.

void invertDisplay()
{
    TFT_RD = 1;
    TFT_WR = 1;
    __delay_ms(1);
    TFT_CS = 0;//
    TFT_RS = 0;//D/C
    TFT_WR = 0;
    __delay_ms(1);
    LATD = 0x21;
    __delay_ms(1);
    TFT_WR = 1;
    TFT_RS = 1;
    TFT_CS = 1;
}

thanks in advance 

david_prentice

If the shield works on a Uno,  you can tell us what ID the controller has.

Only "MIPI-style" controlers will understand the "Invert Display On" command.
Even then,   it will only be visible if the "Invert Display Off" command is currently in effect.

David.

baijusuno

Hi, David
              The ID given by uno is 9338. I tried to reset the display using the reset pin and also by sending the command(0x01),as there is no indication to ensure whether the driver chip got reset or not, I sent the invert display command as above.The aim was to verify the method i used to communicate with the display is ok
I used the UNO also to communicate to the display as below. if the code is not ok.pls point out the mistakes

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
//pinMode(A0,OUTPUT);

void setup() {
  // put your setup code here, to run once:
  pinMode(A0,OUTPUT);
  pinMode(A1,OUTPUT);
  pinMode(A2,OUTPUT);
  pinMode(A3,OUTPUT);
  pinMode(A4,OUTPUT);
//digitalWrite(LCD_RD,1);
void reset();
{
digitalWrite(LCD_WR, 1);
digitalWrite(LCD_CD, 1);
digitalWrite(LCD_CS, 1);
digitalWrite(LCD_RESET, 1);
delay(100);
digitalWrite(LCD_CD, 0);
digitalWrite(LCD_RESET, 0);
delay(100);
digitalWrite(LCD_RESET, 1);
delay(200);

}
void invertDisplay();
{
  digitalWrite(LCD_RD, 1);
  digitalWrite(LCD_WR, 1);
  delay(1);
  digitalWrite(LCD_CS, 0);
  digitalWrite(LCD_CD, 0);
  digitalWrite(LCD_WR, 0);
  digitalWrite(PIND0, 0);
  digitalWrite(PIND1, 0);
  digitalWrite(PIND2, 1);
  digitalWrite(PIND3, 0);
  digitalWrite(PIND4, 0);
  digitalWrite(PIND5, 0);
  digitalWrite(PIND6, 0);
  digitalWrite(PIND7, 1);
  //PORTD = 0X21;        //Tried this also
  delay(1);
  digitalWrite(LCD_WR, 1);
  digitalWrite(LCD_CD, 1);
  digitalWrite(LCD_CS, 1);
}
// 
}

void loop() {
  // put your main code here, to run repeatedly:

}

david_prentice

The ILI9338 should understand 0x21 and 0x20 commands.  ("Invert Display On" and "Invert Display Off")

I have no idea what your PIND5 pins might be.
Or how you have wired a ready-made shield to some unknown Arduino board.

Let's face it.   Your display needs several initialisation commands to start operating in the first place.
Before you have a visible picture that you want to "invert".

If you have a PIC18F46k22 pcb with proper Arduino header sockets that runs a regular Arduino "core",  I will show you how to run MCUFRIEND_kbv.

If you have a bare PIC18F46k22 chip on a breadboard,  you will have to do everything yourself.

David.

baijusuno

Hi David,
              display pins D0 to D7 are connected to PORTD pins 0 to 7 of PIC
             
               LCD_RST to PORTC pin 4

               LCD_CS to PORTC pin 3

               LCD_RS to PORTC pin 2

               LCD_WR to PORTC PIN1

               LCD_RD to PORTC pin0 (PORTC pins  0 to 4 of pic )

               GND to system GND

               5V to 5V

               3.3V to (Onboard 5V to 3.3V Regulater o/p)

I tried the same method with my UNO R3 also. That code is in my previous post
pls tell me what are the initialisations needed.

david_prentice

Google could only find this PICCININO UNO project

If you have a real pcb with a real Arduino core I can help.
If you are using a bare chip with no Arduino core software,  you are on your own.

David.

Go Up