Author Topic: TFT startup Problem - Solved  (Read 2697 times)

0 Members and 1 Guest are viewing this topic.

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
TFT startup Problem - Solved
« on: May 12, 2017, 11:13:17 am »
I have a problem that I don't know were to start troubleshooting. I notice the problem yesterday as I have not power down the prototype. Eventually the project will have a 2560 but for the proto I'm using an Arduino mega 2560. When I power up the board I can see the screen reset but starts to print garbage, squares, lines etc and it also has an slight flicker. Resetting the Arduino, repeats the sequence of squares and lines. Repowering the unit repeats the sequence. The only way to restore the screen is by reloading the Arduino, then works perfectly until the next power down.
Is anyone encounter this problem?
« Last Edit: May 14, 2017, 12:35:51 pm by dan3460 »
 

Offline ale500

  • Frequent Contributor
  • **
  • Posts: 415
Re: TFT startup Problem
« Reply #1 on: May 12, 2017, 11:45:30 am »
Tell us what for a TFT, controller, interface, reset, driver and so on. It is difficult to troubleshoot something we do not know anything about.

If you are using one of those ILI9xxx (Or renesas based) powered small TFT: The reset of the display seems to play a big role, a nice low pulse after powerup and a delay before writing anything to the display (like in the Adafruit examples) seems to work wonders :).

But please, tell us about your setup for relevant (hopes up) info !
 

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: TFT startup Problem
« Reply #2 on: May 13, 2017, 01:20:17 am »
Sorry about that, one think that the whole world have read the other posts.

It is one of those ILI9342, i'm connected at 8bit, there is a reset pin that is pulsed high and low a few times. Do know what do you mean with driver. I'm programing using Atmel Studio, I have a Arduino nano that's I converted in a AVRISP and using AVRDUDE to load the program.
I was hoping that someone had the same problem and will tell me exactly what I needed to do, I was trying to avoid putting the logic analyzer on the bus to see what is going on.
 

Offline ale500

  • Frequent Contributor
  • **
  • Posts: 415
Re: TFT startup Problem
« Reply #3 on: May 13, 2017, 05:07:58 am »
The "driver" is the small piece of code that *drives* the display. Adafruit has in its github repository a driver for such a display. It works and it is for arduino. You have to choose the version with 8 bit BUS and not the one with SPI output (for smaller displays). And get the pin out right in case it is different to what they sell.
My display is being driven by a FPGA, so I ported the "code" for it, so to say. That is why I talked about reset sequence and timing. I had to use the logic analyzer too, don't be afraid !
 

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: TFT startup Problem - Solved
« Reply #4 on: May 14, 2017, 12:46:50 pm »
In case anyone is following this post I solved the problem. I don't remember where I got the library that I'm using and I don't remember if the class I named or the author named. In any case here is the header file, note that some functions I added.
Code: [Select]
#ifndef __TFTSCREEN_H__
#define __TFTSCREEN_H__
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
#include <avr/pgmspace.h>
#include <limits.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdbool.h>
#include "colors_fonts.h"

#define CTR_PORT PORTF // Register where the control ports are located
#define CTR_DDR DDRF // To set up direction of the control ports
#define DATA_BUS PORTK // Register where bus data located

#define BUS_DDR DDRK // To set up direction of the bus pins

#define RST_PORT PORTF // Register where the reset pin is located
#define RST_DDR DDRF // To set up direction of the reset pin

#define READ_PORTK PINK // To read values of the register D


// Below are described the pins used for the data bus on the LCD
#define LCD_D2 PK2
#define LCD_D3 PK3
#define LCD_D4 PK4
#define LCD_D5 PK5
#define LCD_D6 PK6
#define LCD_D7 PK7
#define LCD_D0 PK0
#define LCD_D1 PK1

#define LCD_RST PF3 //Screen hardware reset
#define LCD_CS PF4 // Chip select, making this H will cause the chip not to respond to commands or data
#define LCD_RS PF5 // This is the C/D (command or data) selection
#define LCD_WR PF6 // Write pin
#define LCD_RD PF7 // Read pin

#define TFTHEIGHT 240
#define TFTWIDTH 320

#define _swap_int16_t(a, b) { int16_t t = a; a = b; b = t; }
#define pgm_read_pointer(addr) ((void *)pgm_read_dword(addr))

class TFTScreen
{
//variables
public:

protected:
GFXfont  *gfxFont;
bool wrap;   // If set, 'wrap' text at right edge of display
bool _cp437; // If set, use correct CP437 charset (default is off)
private:
volatile uint16_t cursor_x;
volatile uint16_t cursor_y;
volatile uint16_t textcolour;
volatile uint16_t textbgcolour;
volatile uint8_t textsize;
uint16_t vsetx,vsety,vactualx,vactualy,isetx,isety,iactualx,iactualy;
uint16_t LCD_W;
uint16_t LCD_H;
/* Parameters to be displayed at the screens */
bool celsFar; // True display in Celsius, false display in Fahrenheit.
float tempHeatSink; // This maintains the last measured temperature of the heat sink
float tempCase; // This maintains the last measured temperature of the enclosure


//Basic functions
public:
TFTScreen();
~TFTScreen();

void setCursor(uint16_t x,uint16_t y);
void setTextColour(uint16_t x,uint16_t y);
void setTextSize(uint8_t s);
void write(uint8_t c);
void writeString(const char *strLine);
void screenInit(void);
void clear(uint16_t colour);
void setRotation(uint8_t x);
void pushColour(uint16_t colour);
void drawChar(int16_t x, int16_t y, unsigned char c,uint16_t color, uint16_t bg, uint8_t size);
void drawPixel(uint16_t x3,uint16_t y3,uint16_t colour1);

void drawLine(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1, uint16_t color);

void fillRect(uint16_t x,uint16_t y,uint16_t w,uint16_t h,uint16_t colour);
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
void cp437(bool x=true);
void setFont(const GFXfont *f = NULL);

protected:

private:
TFTScreen( const TFTScreen &c );
TFTScreen& operator=( const TFTScreen &c );

void hard_init(void);
void writeCommand8(uint8_t com);

void writeData8(uint8_t data);
void setAddress(uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2);
void hard_reset(void);

void backupLocationVset(void);
void backupLocationVactual(void);
void backupLocationIset(void);
void backupLocationIactual(void);

int celsToFar(float temp);


// Display functions
public:
void screen1(void); // This is the main working display


void showHeatTemp(uint16_t temp);
void showCaseTemp(uint16_t temp);
void showHeatFan(bool onOff);
void showCaseFan(bool onOff);

}; //TFTScreen

#endif //__TFTSCREEN_H__
The problem was with the initial setup of the font, the function setFont() was not called any where. For the basic font variable GFXfont need to be setup to NULL. I'm guessing that when the program was put in memory by the programmer the memory space pointed by the variable was an empty space, but after power down the chip that piece of memory had garbage and the program go lost trying to print characters.
The solution was to call setFont(NULL) when the constructor of the class was called.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf