TFT DRIVER ISSUES

Beta Testing discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
hell3
Posts: 2
Joined: 06 Feb 2011 19:24

TFT DRIVER ISSUES

#1 Post by hell3 » 06 Feb 2011 20:35

Hello this is great job same familiar IDE, librarys and flexibility as microc for AVR that i bought recently.For now i have a LV32MX V6 board with a TFT display with 320x240 resolution.I have download the pic32 Beta compiler and i try to initialise the display and some extra functions.As the example says you have to include this:

// TFT display connections
char TFT_DataPort at LATE;
sbit TFT_WR at LATD13_bit;
sbit TFT_RD at LATD12_bit;
sbit TFT_CS at LATC3_bit;
sbit TFT_RS at LATB15_bit;
sbit TFT_RST at LATC1_bit;

char TFT_DataPort_Direction at TRISE;
sbit TFT_WR_Direction : at TRISD13_bit;
sbit TFT_RD_Direction at TRISD12_bit;
sbit TFT_CS_Direction at TRISC3_bit;
sbit TFT_RS_Direction at TRISB15_bit;
sbit TFT_RST_Direction at TRISC1_bit;
// End of TFT display connections
So you can define the I/O'S.I have other pins in the board like WR=D4_bit RD=D5_bit CS=F12_bit.Ok i change that with correct ones but i have wrong colors in objects.The example says that the lib initialise the display in 8bit mode and as i notice if you close the high byte switches also change the color to permanent colors like blue.I wrote some text too in my first project and next i try to make another project
with a rec draw function the result was a mixed picture of my first project text and a rectangular of my second project.What might cause that,can you help me please? :?

p.erasmus
Posts: 3391
Joined: 05 Mar 2009 10:28

Re: TFT DRIVER ISSUES

#2 Post by p.erasmus » 06 Feb 2011 21:04

By just posting the data port code is not helping much
can you post the actual code you are using and the Configuration you use for the Configuration bits !
P.Erasmus
Saratov,Russia
--------------------------------------------------------------

Toley
Posts: 922
Joined: 03 Sep 2008 16:17

Re: TFT DRIVER ISSUES

#3 Post by Toley » 07 Feb 2011 00:18

Hi hell3,

I'm not using the LV32MX V6 board I'm using a MMB 32MX4 board but from another post marko tell me the display are the same.

If you want to use the TFT library with your own code, you have to initialize the display like in the example cause the board use 16 bits PMP port not 8 bits. The command TFT_Set_Active(SetIndex,WriteCommand,WriteData); seems to give the possibility to use custom function to talk to the display.

It work for me but I'm still unable to make the touch screen works :( . I will appreciate if you can tell me if yours works.

Code: Select all

unsigned short TFT_DataPort at LATE; //               // DATA port
unsigned short TFT_DataPort_Direction at TRISE;                   // DATA port

sbit TFT_RST_Direction at TRISC1_bit;
sbit TFT_RST  at LATC1_bit;

sbit TFT_RS_Direction  at TRISB15_bit;
sbit TFT_RS   at LATB15_bit;

sbit TFT_CS_Direction  at TRISF12_bit;
sbit TFT_CS   at LATF12_bit;

sbit TFT_RD_Direction  at TRISD5_bit;
sbit TFT_RD   at LATD5_bit;

sbit TFT_WR_Direction  at TRISD4_bit;
sbit TFT_WR   at LATD4_bit;

// Touch Panel module connections
sbit DriveX_Left at LATB13_bit;
sbit DriveX_Right at LATB11_bit;
sbit DriveY_Up at LATB12_bit;
sbit DriveY_Down at LATB10_bit;
sbit DriveX_Left_Direction at TRISB13_bit;
sbit DriveX_Right_Direction at TRISB11_bit;
sbit DriveY_Up_Direction at TRISB12_bit;
sbit DriveY_Down_Direction at TRISB10_bit;
// End Touch Panel module connections

// Global variables
unsigned int Xcoord, Ycoord;
char PenDown;
void *PressedObject;
unsigned int caption_length, caption_height;
unsigned int display_width, display_height;

void PMPWaitBusy() {
  while(PMMODEbits.BUSY);
}

void SetIndex(unsigned short index) {
  TFT_RS = 0;
  PMDIN = index;
  PMPWaitBusy();
}

void WriteCommand( unsigned short cmd ) {
  TFT_RS = 1;
  PMDIN = cmd;
  PMPWaitBusy();
}

void WriteData(unsigned int _data) {
  TFT_RS = 1;
  PMDIN = _data;
  PMPWaitBusy();
}


static void InitializeTouchPanel() {
  AD1PCFG = 0xFFFF;
  PCFG12_bit = 0;
  PCFG13_bit = 0;

  // PMP setup
  PMMODE = 0;
  // PMAEN: Parallel Master Port Address Enable Register
  PMAEN  = 0;  // sve seovano na 0 znaci pinovi se ne koriste kao adresni vec normalni I/O
  PMCON  = 0;  // WRSP: Write Strobe Polarity bit
               // 0 = Read strobe active-low (PMWR) - 0 je setovano po resetu
  LATD0_bit = 0;
  //  PMCON = 0x1b03;
  //  PMMODE = 0x60A;
  PMMODE = 0;
  PMAEN = 0;
  PMCON = 0;
  PMMODEbits.MODE = 2; // Master 2
  PMMODEbits.WAITB = 0;
  PMMODEbits.WAITM = 1;
  PMMODEbits.WAITE = 0;
  PMMODEbits.MODE16 = 1; // 16 bit mode
  PMCONbits.CSF = 0;
  PMCONbits.PTRDEN = 1;
  PMCONbits.PTWREN = 1;
  PMCONbits.PMPEN = 1;
  TRISE = 0;
  TRISD = 0;


  TFT_Set_Active(SetIndex,WriteCommand,WriteData);
  TFT_Rotate_180(1);
  TFT_Init(320, 240);

  //TP_TFT_Init(320, 240, 0, 1);                                  // Initialize touch panel
  TP_TFT_Init(320, 240, 13, 12);                                  // Initialize touch panel
  TP_TFT_Set_ADC_Threshold(900);                              // Set touch panel ADC threshold

  PenDown = 0;
  PressedObject = 0;
}
Serge T.
Learning is an endeless process but it must start somewhere!

User avatar
marko.ziv
mikroElektronika team
Posts: 530
Joined: 06 Dec 2007 10:11
Contact:

Re: TFT DRIVER ISSUES

#4 Post by marko.ziv » 07 Feb 2011 09:25

Hello,

issue addressed on this topic
http://www.mikroe.com/forum/viewtopic.p ... 62#p142162

Best Regards

hell3
Posts: 2
Joined: 06 Feb 2011 19:24

Re: TFT DRIVER ISSUES

#5 Post by hell3 » 07 Feb 2011 18:01

p.erasmus wrote:By just posting the data port code is not helping much
can you post the actual code you are using and the Configuration you use for the Configuration bits !
Hello p.erasmus thanks for posting i'am just testing the TFT library and my code is simple as this

// TFT display connections
char TFT_DataPort at LATE;
sbit TFT_WR at LATD4_bit;
sbit TFT_RD at LATD5_bit;
sbit TFT_CS at LATF12_bit;
sbit TFT_RS at LATB15_bit;
sbit TFT_RST at LATC1_bit;
char TFT_DataPort_Direction at TRISE;
sbit TFT_WR_Direction at TRISD4_bit;
sbit TFT_RD_Direction at TRISD5_bit;
sbit TFT_CS_Direction at TRISF12_bit;
sbit TFT_RS_Direction at TRISB15_bit;
sbit TFT_RST_Direction at TRISC1_bit;
// End of TFT display connections

void main(){
TFT_Init(240, 320);//works fine (orientation)
TFT_Fill_Screen(CL_WHITE);//works fine only with white color
TFT_Set_Font(TFT_defaultFont, CL_BLACK, FO_VERTICAL);
TFT_Write_Text("TFT LIBRARY DEMO, WELCOME !", 120, 230);//right text orientation but wrong text color
}

about bit configuration from edit project, if you choose Load scheme there is a configuration file for pic32mx460f512l 8 to 80Mhz with PLL
i use that file works fine with other functions(UART......)

helgrind
Posts: 3
Joined: 06 May 2011 15:04
Location: Guildford, UK

Re: TFT DRIVER ISSUES

#6 Post by helgrind » 06 May 2011 18:12

Hi,

I'm really quite confused :S

So TFT uses a 16 bit interface over the PMP. I thought TFT_Init() would have set up the comms routines, but in the codes I have seen you need to specify them, as above. Thats fine. The problem is I have seen 2 versions, one actually specifies pins, the other uses PMDIN. Now as far I can see, one half of the data bits is on Lo(LATE), but the other half is spread across many ports. I used the older? version of the comms routines and linked all the Hi(_data) bits to their respective different pins. This gave an improvement, and let me see green pixels on my display.

Alternatively, if I use the 'PMDIN' version, I have to specify the PMP setup for it to show green.

My main problem at the moment, apart from the confusion, is that I cannot draw shapes, or get Visual TFT code to work. Also sometimes the display only works while in bootloader mode (ie first 5 seconds), then goes to black. Sometimes it only works when you hit reset too.

Any ideas? Dodgy bootloader?

Thanks, Laurence

NOTE I have changed the CS pins to the right ones (as shown in the schematic and that work)

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: TFT DRIVER ISSUES

#7 Post by filip » 09 May 2011 12:13

Hi,

Which development system are you using ?

Regards,
Filip.

helgrind
Posts: 3
Joined: 06 May 2011 15:04
Location: Guildford, UK

Re: TFT DRIVER ISSUES

#8 Post by helgrind » 10 May 2011 22:14

Hi,

MikroMMB for PIC32 - with an MX460F512L. I just bought it.

Thanks,
Laurence

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: TFT DRIVER ISSUES

#9 Post by filip » 18 May 2011 12:49

Hi,

Have you tried the examples distributed with the compiler ?
In those examples you will see what connections are used and how the TFT in configured.

Regards,
Filip.

helgrind
Posts: 3
Joined: 06 May 2011 15:04
Location: Guildford, UK

Re: TFT DRIVER ISSUES

#10 Post by helgrind » 01 Jun 2011 17:37

Hi Filip,

Yeah I've tried all of the examples and they all work fine. However when I try and compile code I get the problems above, eg no circles or anything more complex than a straight line, and none of the visual tft stuff is working either. I got a Pickit2 today to try and isolate the bootloader, but it seems that is not where the problem lies...

Regards,
Laurence

IanRogers
Posts: 8
Joined: 14 Jun 2014 22:04

Re: TFT DRIVER ISSUES

#11 Post by IanRogers » 07 Feb 2015 14:28

When using pic32.... Just check which pins the JTAG is on... To be sure use this.. "JTAGEN_bit =0;"

Also the Open collectors on your Data port need to be off!

Post Reply

Return to “mikroC PRO for PIC32 Beta Testing”