Jump to content
43oh

[Library] Color LCD graphics library


Recommended Posts

  • Replies 35
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Here are 2 graphics libraries that can be used with my Color LCD BoosterPacks as well as some other LCDs   ugl8tiva works with: 1.8" JD-T1800 ST7735 2.2" ILI9225 (with touch panel or without, but

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 ar

EDIT: I got it to work:     I have it wired up as this:   Tiva -> ST7735R LITE -> Vcc MISO -> B6 SCK-> B4 MOSI -> B7 TFT-CS -> A4 DC -> E4 Reset -> Vcc Vcc -> V

Posted Images

EDIT: I got it to work:

 

 

I have it wired up as this:

 

Tiva -> ST7735R

LITE -> Vcc

MISO -> B6

SCK-> B4

MOSI -> B7

TFT-CS -> A4

DC -> E4

Reset -> Vcc

Vcc -> Vcc

GND -> GND

 

Vcc is 3.3V

 

 

What i changed in tiva.c

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


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


void initTiva() {


// run @80MHz, use 16MHz xtal
MAP_SysCtlClockSet (
SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
| SYSCTL_XTAL_16MHZ);


MAP_SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOA);
MAP_SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOB);
MAP_SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOE);
MAP_SysCtlPeripheralEnable (SYSCTL_PERIPH_SSI2);


// #define LCD_SCLK_PIN GPIO_PIN_4
//#define LCD_MOSI_PIN GPIO_PIN_7
//#define LCD_CS_PIN GPIO_PIN_5
//#define LCD_DC_PIN GPIO_PIN_5
MAP_GPIOPinTypeGPIOOutput (GPIO_PORTA_BASE, LCD_CS_PIN);
MAP_GPIOPinTypeGPIOOutput (GPIO_PORTE_BASE, LCD_DC_PIN);
MAP_GPIOPinConfigure (GPIO_PB4_SSI2CLK);
MAP_GPIOPinTypeSSI (GPIO_PORTB_BASE, GPIO_PIN_4);
MAP_GPIOPinConfigure (GPIO_PB7_SSI2TX);
MAP_GPIOPinTypeSSI (GPIO_PORTB_BASE, GPIO_PIN_7);


// ILI9340's max SPI clk is 15MHz, ILI9341's 10MHz
// however, 320x240 LCD (ILI9341) works good @16M or higher
MAP_SSIConfigSetExpClk (SSI2_BASE, MAP_SysCtlClockGet (),
SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 8000000, 8);


MAP_SSIEnable (SSI2_BASE);
}


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


// code duplication, but we are saving clock cycles by not passing dataCommand
void writeData(u_char data) {
LCD_SELECT;
LCD_DC_DATA;


SSI2_DR_R = data;
while (SSI2_SR_R & SSI_SR_BSY) {
};


LCD_DESELECT;
}


// code duplication, but we are saving clock cycles by not passing dataCommand
void writeCommand(u_char command) {
LCD_SELECT;
LCD_DC_CMD;


SSI2_DR_R = command;
while (SSI2_SR_R & SSI_SR_BSY) {
};


LCD_DESELECT;
}


/*
 * long delay
 */
void delay(u_char x10ms) {
MAP_SysCtlDelay( (MAP_SysCtlClockGet()/(3*100))*x10ms ) ;
}
And the correlating tiva.h
/*
 * tiva.h
 *
 *  Created on: Apr 4, 2014
 *      Author: RobG
 */


#ifndef TIVA_H_
#define TIVA_H_


#include "typedefs.h"
//
//
//
void initTiva();
void writeData(u_char data);
void writeCommand(u_char command);
void delay(u_char x10ms);
//
#define COMMAND 0
#define DATA 1
//
///////////////
// clock
#define LCD_SCLK_PIN GPIO_PIN_4
// data out
#define LCD_MOSI_PIN GPIO_PIN_7
// chip select
#define LCD_CS_PIN GPIO_PIN_4
#define LCD_SELECT GPIO_PORTB_DATA_R &= ~LCD_CS_PIN
#define LCD_DESELECT GPIO_PORTB_DATA_R |= LCD_CS_PIN
// data/control
#define LCD_DC_PIN GPIO_PIN_4
#define LCD_DC_CMD GPIO_PORTE_DATA_R &= ~LCD_DC_PIN
#define LCD_DC_DATA GPIO_PORTE_DATA_R |= LCD_DC_PIN
//
#endif /* TIVA_H_ */

Might have to unplug and replug the tiva in and out to cycle it. Hope this helps!

Link to post
Share on other sites
  • 2 weeks later...
  • 4 weeks later...
  • 11 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...