ILI9341 8 bit mode

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

To write the 16 bit data register, you put out the low 8 bits first, set WR low, set WR high, the put out the high 8 bits, set WR low and back high?

Somehow, every "8 bit" example I find puts the 2 halves to 2 ports and clocks the WR low and back high. Sounds like 16 bits to me.

(Yes, I'm at it again.)

void TSLCDOutDat(unsigned short dat) //write data to LCD
{
		LCDRDhi;
		LCDRShi;
		LCDCSlo;
		LCDData.OUT = dat>>8;
		LCDWRlo;
		LCDWRhi;
		LCDData.OUT = dat & 255;
		LCDWRlo;
		LCDWRhi;

}

void TSLCDOutDat2(unsigned char dath,unsigned char datl) //write data to LCD
{
	
		LCDRDhi;
		LCDRShi;
		LCDCSlo;
		LCDData.OUT = dath;
		LCDWRlo;
		LCDWRhi;
		LCDData.OUT = datl;
		LCDWRlo;
		LCDWRhi;
	
}

void TSLCDOutIns(unsigned short ins) //write instruction to LCD
{
		LCDRDhi;
		LCDRSlo;
		LCDCSlo;
		LCDData.OUT = ins >>8 ;
		LCDWRlo;
		LCDWRhi;
		LCDRShi;
		LCDData.OUT = ins & 255;
		
}

uint16_t TSLCDInDat(void) //read data from LCD
{
	uint16_t d ;
		LCDWRhi;
		LCDRSlo;
		LCDCSlo;
		LCDRDlo;
		NOP;
		
		d = LCDData.IN << 8;
		LCDRDhi;
		LCDRDlo;
		d  = d | LCDData.IN;
		LCDRDhi;
		return d;
}

unsigned short TSLCDInIns(void) //read data from LCD
{
	LCDRSlo;
	LCDCSlo;
	unsigned short ins = 0;
	LCDWRhi;
	LCDRDlo;
	NOP;
	ins = LCDData.IN;
	LCDRDhi;
	LCDCShi;
	return ins;
}

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

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

This is what I'm using, I think you need to write to the top 8 bits (even if rubbish- 0 in the case below) in 8 bit mode.

The SPI mode was very specific to one of the controllers (can't remember which)

void GLCD_Write_Data (unsigned int val) 
{ 

// RS = 0 (bit 1) index register write. RS = 1 Data or instruction
// R\W = 0 (bit 0) write, R\W = 1 read

#if defined GLCD_SPI_MODE
	GLCD_SPI_PORT &= ~ (1<<SS);		// Select chip
	SPDR = 0x72;					// Start byte 0111 00 20
	while (!(SPSR & (1<<SPIF)));
	SPDR = (val>>8);				// Send MSB
	while (!(SPSR & (1<<SPIF)));
	SPDR = (val);					// Send lsb
	while (!(SPSR & (1<<SPIF)));								//0111 00
	GLCD_SPI_PORT |= (1<<SS);		//De-select chip
#elif defined GLCD_8_BIT_MODE
    GLCD_CLR_CS();					// clear CS pin to ENABLE LCD 
	GLCD_SET_DB (val>>8);
	GLCD_CLR_WR ();
	GLCD_SET_WR ();
	GLCD_SET_DB(val);
	GLCD_CLR_WR();
	GLCD_SET_WR();
	GLCD_SET_CS();					// set CS pin to DISABLE LCD
#else
    GLCD_CLR_CS();					// clear CS pin to ENABLE LCD 
	GLCD_SET_DBH(val>>8);
	GLCD_SET_DBL(val);
	GLCD_CLR_WR();
	GLCD_SET_WR();
    GLCD_SET_CS();					// set CS pin to DISABLE LCD
#endif	 
} 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

It's ignoring anything I tell it. Must have the wrong signal on one of the pins.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

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

Scoped out all the signals. All are correct, or at least according to my understanding of correct. Of course, if my understanding was correct, the silly thing would be working.

I thought it was displaying a pink Y, but the Y was just printed on the protective cover.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

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

I have never used the ILI9341, I have some code snippets but I think were written for another unkown processor and compiler.

Do you REALLY need to use 8 bit mode? 16 bit is nicer and of course faster.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

The speed advantage of 16-bit over 8-bit is fairly trivial. i.e. it saves one CBI,SBI or 4 cycles. (2 cycles if you used OUT,OUT). Bear in mind that the AVR is an 8-bit MCU.

I have just ordered an SPI ILI9341 module. I would guess that it will be indistinguishable from an SPI ILI9320 module. As always, I steer clear of the bare modules which require clever soldering and most of my GPIO lines.

Oh, Mr Samperi's snippet shows just how simple the actual SPI/8-bit/16-bit output functions are on an ILI932x chip. (I haven't downloaded the ILI9341 data sheet yet -- I bet it is similar)

David.

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

As I said the SPI function was not for a ILIxxxx :-) I think it was a RWxxxx something.

SPI seems quite different from chip to chip.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I used 8 'cause I was running out of pins on my 44pin TQFP.

I think the "command" is just 1 byte, while the "data" is 2 and you write the MSB first. I'm looking at http://www.newhavendisplay.com/a...

Of course, I don't know why it didn't work

I think whoever answers their forum is on vacation.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut.