SSD1963 TFT Color issue on SAMD21

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

I have a SAMD21 driving a SSD1963 TFT. For some reason, Black and Green are reversed but Red and Blue are fine. I am running the TFT on a 16 bit bus and the colors are RGB (565) format. I've combed over the datasheet and I am at a loss. Any help is appreciated. Here is my config:

 

sam_writeCom(0xE2);		        //PLL multiplier, set PLL clock to 120M
sam_writeByteData(0x23);	        //N=0x36 for 6.5M, 0x23 for 10M crystal
sam_writeByteData(0x02);
sam_writeByteData(0x54);
sam_writeCom(0xE0);			// PLL enable
sam_writeByteData(0x01);
delay_ms(10);
sam_writeCom(0xE0);
sam_writeByteData(0x03);
delay_ms(10);
sam_writeCom(0x01);			// software reset
delay_ms(100);
sam_writeCom(0xE6);			//PLL setting for PCLK, depends on resolution
sam_writeByteData(0x01);
sam_writeByteData(0x1F);
sam_writeByteData(0xFF);
sam_writeCom(0xB0);			//LCD SPECIFICATION
sam_writeByteData(0x20);
sam_writeByteData(0x00);
sam_writeByteData(0x01);		//Set HDP	479
sam_writeByteData(0xDF);
sam_writeByteData(0x01);		//Set VDP	271
sam_writeByteData(0x0F);
sam_writeByteData(0x00);
sam_writeCom(0xB4);			//HSYNC
sam_writeByteData(0x02);		//Set HT	531
sam_writeByteData(0x13);
sam_writeByteData(0x00);		//Set HPS	8
sam_writeByteData(0x08);
sam_writeByteData(0x2B);		//Set HPW	43
sam_writeByteData(0x00);		//Set LPS	2
sam_writeByteData(0x02);
sam_writeByteData(0x00);
sam_writeCom(0xB6);				//VSYNC
sam_writeByteData(0x01);		//Set VT	288
sam_writeByteData(0x20);
sam_writeByteData(0x00);		//Set VPS	4
sam_writeByteData(0x04);
sam_writeByteData(0x0c);		//Set VPW	12
sam_writeByteData(0x00);		//Set FPS	2
sam_writeByteData(0x02);
sam_writeCom(0xBA);
sam_writeByteData(0x0F);		//GPIO[3:0] out 1
sam_writeCom(0xB8);
sam_writeByteData(0x07);	    //GPIO3=input, GPIO[2:0]=output
sam_writeByteData(0x01);		//GPIO0 normal

sam_writeCom(0x36);				//rotation
sam_writeByteData(0x22);
sam_writeCom(0xF0);				//pixel data interface
sam_writeByteData(0x03);
delay_ms(1);
sam_setXY(0, 0, tft_conf.height , tft_conf.width);
sam_writeCom(0x29);				//display on

sam_writeCom(0xBE);				//set PWM for B/L
sam_writeByteData(0x06);
sam_writeByteData(0xf0);
sam_writeByteData(0x01);
sam_writeByteData(0xf0);
sam_writeByteData(0x00);
sam_writeByteData(0x00);
sam_writeCom(0xd0);
sam_writeByteData(0x0d);
sam_writeCom(0x2C);		

This topic has a solution.

"When all else fails, read the directions"

Last Edited: Tue. Oct 31, 2017 - 01:16 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't see you setting 565 mode anywhere.   e.g. writing 0x5 to reg(0x3A)

Nor do I see any graphics code.   Please attach a buildable project.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Nor do I see any graphics code.

Hi David,

 

Thank you for the help. As adviced, I added the 2 lines to set the pixel format, Still the same issues. Has me scratching my head. Attached are the files you need. Here is the implementation:

 

#include <asf.h>
#include "string.h"
#include "conf_usart.h"
#include "sam_tft.h"
#include "character_map.h"
#include "arcena_22pt.h"

#define CHARCT 95

/* TFT Functions*/
void init_tft(void);

/* Font Functions*/
void setArcena22Font(void);

int PAGE1 = 0;
int PAGE2 = 272;
int PAGE3 = 544;

int main (void)
{
	system_init();
	configure_console(115200);
	delay_init();
	
	init_tft();	
	sam_print("SAMD21 Unifi Project", 1,1);

	while (1) {
		/* Is button pressed? */
		if (port_pin_get_input_level(BUTTON_0_PIN) == BUTTON_0_ACTIVE) {
			/* Yes, so turn LED on. */
			port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);

		} else {
			/* No, so turn LED off. */
			port_pin_set_output_level(LED_0_PIN, !LED_0_ACTIVE);
		}		
	}
}
/* TFT */
void init_tft()
{
	tft_conf.tft_model = SSD1963_480;
	tft_conf.width = 272;
	tft_conf.height = 480;
	tft_conf.pages = 3; // 3 max
	tft_conf.page_1 = 0;
	tft_conf.page_2 = 272;
	tft_conf.page_3 = 543;
	tft_conf.orient = LANDSCAPE;	
	
	sam_setPinIO();
	sam_initTft();
	
	int page_zone = 0;
	
	if(tft_conf.orient == PORTRAIT){
		
		page_zone = tft_conf.width * tft_conf.pages;
		
		} else {
		
		page_zone = (tft_conf.height * tft_conf.pages);
	}
	if(tft_conf.tft_model == SSD1963_480){
		
		sam_setScrollArea(0, page_zone, page_zone);
	}

	sam_setBackColor(0, 0, 0);
	sam_fillScr(0,0,0);	// back ground for page 1
	
	//set up fonts
	setArcena22Font();
	sam_setCharMap(charMap); // standard 95 ascii characters
	
	// set all backgrounds to black (optional for using paging)
	sam_fillPage(0,0,0,1);
	sam_fillPage(0, 0, 0, 2);
	sam_fillPage(0, 0, 0, 3);
	sam_setColor(255, 255, 255);
}

void setArcena22Font(){
	sam_setFont(arcena_22ptBitmaps,arcena_22ptDescriptors, CHARCT);
}

Here is the Pinout:

 

/* 
SamD212 xplained Pro TFT Project. 
This is a port of the Arduino M0 to SAMD21

Notes for SAMD -> PA03 can be used by USB ID or EXT3 PIN4 by changing the position of the jumper JS300 on J307.
Notes -> A SD version example can be found in the SAMD21_TFT_SD_card_example project.
Notes -> Paging only works with the SSD1963
Notes -> Touch is controlled via SPI. 

Uses 8bit 2.4 TFT and 16 for 2.8 TFT
Note the pin layout is different

SAMD21		2.4 TFT		2.8 & SSD1963 TFT
-------------------------------------
PA10		RS			RS
PA11		WR			WR
PA04		CS			CS
PA05		RS_T		RS_T (RESET)


PB00		DB8			DB00
PB01		DB9			DB01
PB02		DB10		DB02
PB03		DB11		DB03
PB04		DB12		DB04
PB05		DB13		DB05
PB06		DB14		DB06	
PB07		DB15		DB07

PB08		----		DB08
PB09		----		DB09
PB10		----		DB10
PB11		----		DB11
PB12		----		DB12
PB13		----		DB13
PB14		----		DB14
PB15		----		DB15

SPI For Touch on EXT2
------------------------------------
SAMD21		TFT		Function
------------------------------------
PA17		T_CS		SS
PA18		T_DIN		MOSI
PA16		T_DO		MISO
PA19		T_CLK		SCK
*/

 

Attachment(s): 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Life is much easier if you ZIP up your AS7 project and attach it.    Preferably after you have checked that all the project files are accessible to a foreign user.

i.e. I can unpack the ZIP into a directory on my PC and build immediately.

It looks as if you are using the initlcd.h from UTFT. library e.g. UTFT_v2.82\tft_drivers\ssd1963\480

I do not own an SSD1963 480x272 panel but a lot of UTFT users own them.

I support SSD1963 480x272 in my MCUFRIEND_kbv library (as a simple library edit) with the same sequence.   But I am not sure whether anyone has used it.

So I can only guess that the initialisation is 100%.   And that your panel is compatible with that initialisation.

Looking at the sam_tft.c file,  the author has a strange way of controlling TFTs.

If you supplied the bitmap of your screenshot,   I could try it on an SSD1963 800x480 panel.

The simple tests would be filled rectangles of different colours.

David.

Last Edited: Sat. Oct 28, 2017 - 01:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Life is much easier if you ZIP up your AS7 project and attach it. 

and, unless you do that, we can't see problems that are due to your project setup!

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Looking at the sam_tft.c file, the author has a strange way of controlling TFTs.

That's me. Keeping with ASF, I am using structs to manage the tfts.

david.prentice wrote:
Life is much easier if you ZIP up your AS7 project and attach it.

Will do, but I need to make a simpler project. Currently images are being loaded from a USB which is irreverent to the issue. The issue is getting the colors correct, which can tested/verified by setting the background colors.

Stand by!

 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Some progress. I decided to load the code onto another SAMD21 to narrow now that its either a code, hardware or wire issue. On the new SAMD21, the colors are correct, so I either have a wiring issue or perhaps a loose solder joint. I will report back.

"When all else fails, read the directions"

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Issue turned out to be a bad wire connection... Thanks all for the help.

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Excellent!

Please mark the solution: https://www.avrfreaks.net/comment...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...