Jump to content
RobG

[Library] Color LCD graphics library

Recommended Posts

One more thing @@brockmid. In my library, SPI is set to 8MHz. Changing it to 16MHz increases drawing speed to ~1200pixels/30ms using drawPixel.

	MAP_SSIConfigSetExpClk (SSI2_BASE, MAP_SysCtlClockGet (),
			SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 16000000, 8);

Share this post


Link to post
Share on other sites

Hi Rob,

 

I connected a scope to the clock signal and looks like the SPI bus is running at 1MHz

(1 / 1 microsecond period). I attached a screen shot of the scope trace.

 

Initially, when I was trying to get the LCD up and running, I downloaded a folder from the 43oh website named "LcdStellaris". It included the colorLCD.h and colorLCD.h files.

 

However, I don't see the SSI Configuration function in either file:

 

"MAP_SSIConfigSetExpClk (SSI2_BASE, MAP_SysCtlClockGet (), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 16000000, 8);"

 

Could you tell me where I can get the file(s) that have this function?

 

So, I don't know how the clock is getting generated cause when I look at the register related to the SSI Module 2 Clock, they're all 0's. I will dig deeper into this, but if you have any code specifically related to setting up the SPI bus that would be helpful.

 

Also, I was able to figure out how to write a pixel without having to set the window address every time. I just call the setArea function once and set it to the screen area I need to draw pixels to. Then, I set the RAM Address (R20h, R21h) to the intended pixel each time I need to write a pixel. This sped things up considerably and cut the time from 187 microseconds to around ~90 microseconds.

 

I think once I can get the SPI running faster, it will definitely make the graphing function run much more fluid.

 

Thanks for all the help,

 

Brock

 

 

 

 

LCD_Clock.bmp

Share this post


Link to post
Share on other sites

Error compiling both libraries in Energia. What IDE are you using to make this work?

 

/Users/xxxxxxx/Documents/Energia/libraries/ugl8tiva/tiva.c:7:31: fatal error: inc/tm4c123gh6pge.h: No such file or directory
compilation terminated.

Share this post


Link to post
Share on other sites

RobG,

 

Please forgive the noob questions; hopefully this won't take too much of your time and help others out along the way.  I recently purchased 4 of you LCD boards and I am trying to bring them up right now.

 

I am attaching them to CC3200 board, (It's a bit different than the board mentioned in the forum, but not by much).  It just seems too cool to have the WiFi on the MCU die; I couldn't pass it up.

 

I have been through both your 430 code and the Tiva code mentioned in this thread, and it seems like a really solid starting point.  I simply looked throught your schematic, and then used the TI pin_mux tool to create the corret setup to match your schematic.  I also had to do a bit of tweaking in the setup code (Isolated to tiva.c) to deal with some board specific things.  The problem is that I still end up staring at a white screen; I can't execute a single command.  It really feels like the ILI9341 is seeing nothing, (or at least responding with nothing).

 

I initially started using the hardware SPI bus controller, and probed as much as I could to get a firm grasp that the board was working as it should.  I even shorted miso<->mosi with jumper and observed that I could read back what I was dumping in.  It sure looks right to me.

 

At this point, I wanted to make it even simpler yet and wrote a bit of code to bit-bang the SPI commands.  Then I could pull off your LCD board and probe each signal as it changed using a debugger and multi-meter.  I have matched the waveform to the timing diagram in the datasheet to the best of my ability...  If it isn't correct, I don't see how.

 

I have checked things like the reset line to make sure that it is being pulled high->low->high before any commands are issued, and that also looks fine.  I guess the bottom line is that it looks the the LCD controller is simply doing nothing, (a bunch of opens and nothing more).  Do you have any thoughts that could steer me down a productive troubleshooting path?

 

I sure appreciate any assitance that you may provide.

 

Here is my adapted tiva.c that only does simple bit-banging:

/*
 * msp.c
 *
 *  Created on: Mar 20, 2012
 *      Author: RobG
 */
#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_types.h"
#include "inc/hw_memmap.h"
#include "inc/hw_gpio.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/gpio.h"
#include "driverlib/spi.h"
#include "tiva.h"
#include "lcd.h"
#include "config.h"

////////////////////////////////////
// init
////////////////////////////////////

void initTiva()
{

}

////////////////////////////////////
// write & delay
////////////////////////////////////

void setClock(unsigned char val)
{
	if(val)
		MAP_GPIOPinWrite(GPIOA1_BASE, 0x40, 0x40);
	else
		MAP_GPIOPinWrite(GPIOA1_BASE, 0x40, 0x00);
}

void setDc(unsigned char val)
{
	if(val)
		MAP_GPIOPinWrite(GPIOA0_BASE, 0x10, 0x10);
	else
		MAP_GPIOPinWrite(GPIOA0_BASE, 0x10, 0x00);
}

void setCs(unsigned char val)
{
	if(val)
		MAP_GPIOPinWrite(GPIOA0_BASE, 0x8, 0x08);
	else
		MAP_GPIOPinWrite(GPIOA0_BASE, 0x8, 0x00);
}

void setReset(unsigned char val)
{
	if(val)
		MAP_GPIOPinWrite(GPIOA2_BASE, 0x40, 0x40);
	else
		MAP_GPIOPinWrite(GPIOA2_BASE, 0x40, 0x00);
}

void setMosi(unsigned char val)
{
	if(val)
		MAP_GPIOPinWrite(GPIOA2_BASE, 0x1, 0x01);
	else
		MAP_GPIOPinWrite(GPIOA2_BASE, 0x1, 0x00);
}

void toggleClock()
{
	setClock(1);
	MAP_UtilsDelay(80000);
	setClock(0);
	MAP_UtilsDelay(80000);
}

void writeData(u_char data)
{
	//set DC high (data mode)
	setDc(1);
	//set first bit on mosi
	setMosi((data >> 7) & 1);
	//set chip select (active low)
	setCs(0);
	//clock in the entire byte
	toggleClock();
	setMosi((data >> 6) & 1);
	toggleClock();
	setMosi((data >> 5) & 1);
	toggleClock();
	setMosi((data >> 4) & 1);
	toggleClock();
	setMosi((data >> 3) & 1);
	toggleClock();
	setMosi((data >> 2) & 1);
	toggleClock();
	setMosi((data >> 1) & 1);
	toggleClock();
	setMosi((data >> 0) & 1);
	toggleClock();
	//disable the chip select
	setCs(1);
}

void writeCommand(u_char command)
{
	//set DC low (command mode)
	setDc(0);
	//set first bit on mosi
	setMosi((command >> 7) & 1);
	//set chip select (active low)
	setCs(0);
	//clock in the entire byte
	toggleClock();
	setMosi((command >> 6) & 1);
	toggleClock();
	setMosi((command >> 5) & 1);
	toggleClock();
	setMosi((command >> 4) & 1);
	toggleClock();
	setMosi((command >> 3) & 1);
	toggleClock();
	setMosi((command >> 2) & 1);
	toggleClock();
	setMosi((command >> 1) & 1);
	toggleClock();
	setMosi((command >> 0) & 1);
	toggleClock();
	//disable the chip select
	setCs(1);
}

/*
 * long delay
 */
void delay(u_char x10ms)
{
	MAP_UtilsDelay(8000000);
	 //MAP_SysCtlDelay( (MAP_SysCtlClockGet()/(3*100))*x10ms ) ;
}


Share this post


Link to post
Share on other sites

Finally got this working...

 

What hung me up is that the schematic here: http://store.43oh.com/index.php?route=product/product&product_id=80

is NOT the correct schematic for the board I have.  This is a schematic for an older version of board.  The newer version

does not have the same chip selects in the same location.  The DC line was also incorrect.  Once I rung out the board

and determined where the nets of interest really were, things came up nicely.

 

Can we organize the correct schematics with the correct revs of the board or somethings similar.  If the correct schematic is available,

I haven't been able to find it yet.  I could just be being dumb here, but I spent a huge amount of time trusting a schematic that I shouldn't

have.  This would have been a 20min fix if I would have been smart enough to ring out the board first.

 

At any rate, this makes me very happy; we are now in a good place to move forward with our product development

Share this post


Link to post
Share on other sites

Finally make my Tiva-C board work with the v3 LCD (2.2" 320x240 ILI9341).

 

Share with newbie to embed programming.

 

1. Download code.

 

ugl16tiva.zip

 

 

2. Build the project.

 

If you are very new to Tiva-C as me, please check this post to trouble shooting how to create and build the code.

 

Here is what I did:

a. download and install ccs

b. download and install tivaware

c. create new empty/hello project

d. try to build it.

e. if success, copy & paste downloaded code to the project folder (delete original hello.c for hello project)

f. add path to tivaware

g. add driverlib.lib to linker's search path.

f. try to build it. (please check this post to trouble shooting)

 

 

3. Checkout the back of the LCD board for the jumpers and compare to the schematic (eg. 2.2 320x240 ILI9341) from post. (There step should be similar for other boards, please check if the schematic available.)

 

a. The v3 board I got has following pins:

board\pin	DC	CS_LCD
MSP	        P1.3	P2.5
TIVA-C	        PE4	PA4

b. Modify the pins and port in tiva.h

 

c. Compare to the old pinout in the downloaded code, Port A is not used in old pinout.


So we add:

MAP_SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOA);

in initTiva().

 

d. Now compile and flash to the board see if you can get it.

Share this post


Link to post
Share on other sites

I just got your 2.4 inch LCD board, with touch screen, and am testing it with the Tiva TM4C123G LaunchPad Evaluation Kit (containing a TM4C123GH6PMI CPU).

I ported the ugl16tiva project into Eclipse CDT with the GNU/ARM plugin.

So far, the display just shows a white background.  The CPU is running because I can toggle the LED on the eval board.

The back of the LCD board says "H24 v2".

Are there incompatiblities between this board and the ugl16tiva project in terms of pinouts or peripheral configuration?

What schematic goes with this board?

What pins on the header correspond to the touch screen resistive sensors?

 

Share this post


Link to post
Share on other sites

Hi,

"H24 v2" uses the same pinout as 2.2 v3 (see post #26) and my lib was not yet updated to reflect that.

 

Default config:

PE4 D/C

PA4 CS LCD

 

The touch pins are:

PA5 PENIRQ

PA6 CS TP

 

And here's the schematic 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×