STM32F103C8 & TFT (ili9325)

Working libraries, libraries being ported and related hardware
neresus
Posts: 9
Joined: Mon Mar 06, 2017 12:57 am

Re: STM32F103C8 & TFT (ili9325)

Post by neresus » Wed Mar 08, 2017 11:07 am

stevestrong wrote:The wiring should be changed in the header file:

Code: Select all

Adafruit_TFTLCD_8bit_STM32.h
yes I rewrite it but still with no luck.
lcd test works ok return lcd id 9325 and others readings are like on arduino uno than I think wiring is good (tested more than one time).
But on your library cannot read LCD id, it return all the time id 0.

lcd test:

Code: Select all

// adapted from LCD_ID_Reader from http://misc.ws/lcd_information
// controllers either read as 16-bit or as a sequence of 8-bit values

//-- Arduino UNO or Mega 2560 Plugged as shield
#define LCD_RST PC13
#define LCD_CS PB11
#define LCD_RS PB10
#define LCD_WR PB9
#define LCD_RD PB8

#define LCD_D0 PA0
#define LCD_D1 PA1
#define LCD_D2 PA2
#define LCD_D3 PA3
#define LCD_D4 PA4
#define LCD_D5 PA5
#define LCD_D6 PA6
#define LCD_D7 PA7

void setup()
{
    Serial.begin(9600);
    while (!Serial) ;
    Serial.println("Read Registers on MCUFRIEND UNO shield");
    Serial.println("controllers either read as single 16-bit");
    Serial.println("e.g. the ID is at readReg(0)");
    Serial.println("or as a sequence of 8-bit values");
    Serial.println("in special locations (first is dummy)");
    Serial.println("");
    lcdInit();
    lcdReset();      //ensures that controller is in default state
//    for (uint16_t i = 0; i < 256; i++) readReg(i, 7, "f.k"); 
    readReg(0x00, 2, "ID: ILI9320, ILI9325, ILI9335, ...");
    readReg(0x04, 4, "Manufacturer ID");
    readReg(0x09, 5, "Status Register");
    readReg(0x0A, 2, "Get Power Mode");
    readReg(0x0C, 2, "Get Pixel Format");
    readReg(0x61, 2, "RDID1 HX8347-G");
    readReg(0x62, 2, "RDID2 HX8347-G");
    readReg(0x63, 2, "RDID3 HX8347-G");
    readReg(0x64, 2, "RDID1 HX8347-A");
    readReg(0x65, 2, "RDID2 HX8347-A");
    readReg(0x66, 2, "RDID3 HX8347-A");
    readReg(0x67, 2, "RDID Himax HX8347-A");
    readReg(0x70, 2, "Panel Himax HX8347-A");
    readReg(0xA1, 5, "RD_DDB SSD1963");
    readReg(0xB0, 2, "RGB Interface Signal Control");
    readReg(0xB4, 2, "Inversion Control");
    readReg(0xB6, 5, "Display Control");
    readReg(0xB7, 2, "Entry Mode Set");
    readReg(0xBF, 6, "ILI9481, HX8357-B");
    readReg(0xC0, 9, "Panel Control");
    readReg(0xC8, 13, "GAMMA");
    readReg(0xCC, 2, "Panel Control");
    readReg(0xD0, 3, "Power Control");
    readReg(0xD2, 5, "NVM Read");
    readReg(0xD3, 4, "ILI9341, ILI9488");
    readReg(0xD4, 4, "Novatek ID");
    readReg(0xDA, 2, "RDID1");
    readReg(0xDB, 2, "RDID2");
    readReg(0xDC, 2, "RDID3");
    readReg(0xE0, 16, "GAMMA-P");
    readReg(0xE1, 16, "GAMMA-N");
    readReg(0xEF, 6, "ILI9327");
    readReg(0xF2, 12, "Adjust Control 2");
    readReg(0xF6, 4, "Interface Control");
}

void loop() 
{
    // put your main code here, to run repeatedly:

}

void printhex(uint8_t val)
{
    if (val < 0x10) Serial.print("0");
    Serial.print(val, HEX);
}

void readReg(uint16_t reg, uint8_t n, const char *msg)
{
    uint8_t val8;
    lcdReset();
    lcdSetWriteDir();
    lcdWriteCommand(0xB0);     //Command Access Protect
    lcdWriteData(0x00);        //looks wrong
/*
    lcdWriteCommand(0xF6);
    lcdWriteData(0x01);
    lcdWriteData(0x01);
    lcdWriteData(0x03);
*/
    lcdWriteCommand(reg);
    Serial.print("reg(0x");
    printhex(reg >> 8);
    printhex(reg);
    Serial.print(")");
    lcdSetReadDir();
    while (n--) {
        val8 = lcdReadData8();
        Serial.print(" ");
        printhex(val8);
    }
    lcdSetWriteDir();
    Serial.print("\t");
    Serial.println(msg);
}

void lcdInit()
{
    pinMode(LCD_CS, OUTPUT);
    digitalWrite(LCD_CS, HIGH);
    pinMode(LCD_RS, OUTPUT);
    digitalWrite(LCD_RS, HIGH);
    pinMode(LCD_WR, OUTPUT);
    digitalWrite(LCD_WR, HIGH);
    pinMode(LCD_RD, OUTPUT);
    digitalWrite(LCD_RD, HIGH);
    pinMode(LCD_RST, OUTPUT);
    digitalWrite(LCD_RST, HIGH);
}

void lcdReset()
{
    digitalWrite(LCD_RST, LOW);
    delay(2);
    digitalWrite(LCD_RST, HIGH);
    delay(10);             //allow controller to re-start
}

void lcdWrite8(uint16_t data)
{
    digitalWrite(LCD_D0, data & 1);
    digitalWrite(LCD_D1, (data & 2) >> 1);
    digitalWrite(LCD_D2, (data & 4) >> 2);
    digitalWrite(LCD_D3, (data & 8) >> 3);
    digitalWrite(LCD_D4, (data & 16) >> 4);
    digitalWrite(LCD_D5, (data & 32) >> 5);
    digitalWrite(LCD_D6, (data & 64) >> 6);
    digitalWrite(LCD_D7, (data & 128) >> 7);
}

uint16_t lcdRead8()
{
    uint16_t result = digitalRead(LCD_D7);
    result <<= 1;
    result |= digitalRead(LCD_D6);
    result <<= 1;
    result |= digitalRead(LCD_D5);
    result <<= 1;
    result |= digitalRead(LCD_D4);
    result <<= 1;
    result |= digitalRead(LCD_D3);
    result <<= 1;
    result |= digitalRead(LCD_D2);
    result <<= 1;
    result |= digitalRead(LCD_D1);
    result <<= 1;
    result |= digitalRead(LCD_D0);

    return result;
}

void lcdSetWriteDir()
{
    pinMode(LCD_D0, OUTPUT);
    pinMode(LCD_D1, OUTPUT);
    pinMode(LCD_D2, OUTPUT);
    pinMode(LCD_D3, OUTPUT);
    pinMode(LCD_D4, OUTPUT);
    pinMode(LCD_D5, OUTPUT);
    pinMode(LCD_D6, OUTPUT);
    pinMode(LCD_D7, OUTPUT);
}


void lcdSetReadDir()
{
    pinMode(LCD_D0, INPUT);
    pinMode(LCD_D1, INPUT);
    pinMode(LCD_D2, INPUT);
    pinMode(LCD_D3, INPUT);
    pinMode(LCD_D4, INPUT);
    pinMode(LCD_D5, INPUT);
    pinMode(LCD_D6, INPUT);
    pinMode(LCD_D7, INPUT);
}

void lcdWriteData(uint16_t data)
{
    lcdSetWriteDir();
    digitalWrite(LCD_CS, LOW);
    digitalWrite(LCD_RS, HIGH);
    digitalWrite(LCD_RD, HIGH);
    digitalWrite(LCD_WR, HIGH);

    lcdWrite8(data >> 8);

    digitalWrite(LCD_WR, LOW);
    delayMicroseconds(10);
    digitalWrite(LCD_WR, HIGH);

    lcdWrite8(data);

    digitalWrite(LCD_WR, LOW);
    delayMicroseconds(10);
    digitalWrite(LCD_WR, HIGH);

    digitalWrite(LCD_CS, HIGH);
}

void lcdWriteCommand(uint16_t command)
{
    lcdSetWriteDir();
    digitalWrite(LCD_CS, LOW);
    digitalWrite(LCD_RS, LOW);
    digitalWrite(LCD_RD, HIGH);
    digitalWrite(LCD_WR, HIGH);
    lcdWrite8(command >> 8);
    digitalWrite(LCD_WR, LOW);
    delayMicroseconds(10);
    digitalWrite(LCD_WR, HIGH);
    lcdWrite8(command);
    digitalWrite(LCD_WR, LOW);
    delayMicroseconds(10);
    digitalWrite(LCD_WR, HIGH);
    digitalWrite(LCD_CS, HIGH);
}

uint8_t lcdReadData8()
{
    uint8_t result;
    lcdSetReadDir();
    digitalWrite(LCD_CS, LOW);
    digitalWrite(LCD_RS, HIGH);
    digitalWrite(LCD_RD, HIGH);
    digitalWrite(LCD_WR, HIGH);

    digitalWrite(LCD_RD, LOW);
    delayMicroseconds(10);
    result = lcdRead8();
    digitalWrite(LCD_RD, HIGH);

    delayMicroseconds(10);

    return result;
}


uint16_t lcdReadData16()
{
    uint16_t result;
    result = lcdReadData8() << 8;
    result |= lcdReadData8();
    return result;
}


void lcdWriteRegister(uint16_t addr, uint16_t data)
{
    lcdWriteCommand(addr);
    lcdWriteData(data);
}

Adafruit_TFTLCD_8bit_STM32.h:

Code: Select all


// IMPORTANT: SEE COMMENTS @ LINE 15 REGARDING SHIELD VS BREAKOUT BOARD USAGE.

// Graphics library by ladyada/adafruit with init code from Rossum
// MIT license

#ifndef _ADAFRUIT_TFTLCD_8BIT_STM32_H_
#define _ADAFRUIT_TFTLCD_8BIT_STM32_H_

    #define PROGMEM
    #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
    #define pgm_read_word(addr) (*(const unsigned short *)(addr))

#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

#include <Adafruit_GFX.h>

#include <libmaple/gpio.h>

/*****************************************************************************/
// LCD controller chip identifiers
#define ID_932X    0
#define ID_7575    1
#define ID_9341    2
#define ID_HX8357D    3
#define ID_UNKNOWN 0xFF

/*****************************************************************************/
#define TFTWIDTH   240
#define TFTHEIGHT  320

// Initialization command tables for different LCD controllers
#define TFTLCD_DELAY 0xFF

// For compatibility with sketches written for older versions of library.
// Color function name was changed to 'color565' for parity with 2.2" LCD
// library.
#define Color565 color565

/*****************************************************************************/
#define	BLACK   0x0000
#define	BLUE    0x001F
#define	RED     0xF800
#define	GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
/*****************************************************************************/
// Define pins and Output Data Registers
/*****************************************************************************/

#define TFT_DATA_PORT	GPIOA
// Port data bits D0..D7:
// enable only one from below lines corresponding to your HW setup:
#define TFT_DATA_LOW_NIBBLE	1 // take the lower 8 bits: 0..7
//#define TFT_DATA_HIGH_NIBBLE	1 // take the higher 8 bits: 8..15

//Control pins |RD |WR |RS |CS |RST|
#define TFT_CNTRL_PORT	GPIOB
#define TFT_RD			PB8
#define TFT_WR			PB9
#define TFT_RS			PB10
#define TFT_CS			PB11
#define TFT_RST			PC13 //PB0

//#define TFT_DATA_PORT	GPIOB
// Port data bits D0..D7:
// enable only one from below lines corresponding to your HW setup:
//#define TFT_DATA_LOW_NIBBLE	1 // take the lower 8 bits: 0..7
//#define TFT_DATA_HIGH_NIBBLE	1 // take the higher 8 bits: 8..15

//Control pins |RD |WR |RS |CS |RST|
//#define TFT_CNTRL_PORT	GPIOA
//#define TFT_RD			PA0
//#define TFT_WR			PA1
//#define TFT_RS			PA2
//#define TFT_CS			PA3
//#define TFT_RST			PB10 //PB0

#define TFT_RD_MASK		BIT0 // digitalPinToBitMask(TFT_RD) // 
#define TFT_WR_MASK		BIT1 // digitalPinToBitMask(TFT_WR) // 
#define TFT_RS_MASK		BIT2 // digitalPinToBitMask(TFT_RS) // 
#define TFT_CS_MASK		BIT3 // digitalPinToBitMask(TFT_CS) // 

#if 0
	// use old definition, standard bit toggling, low speed
	#define RD_ACTIVE    digitalWrite(TFT_RD, LOW)
	#define RD_IDLE      digitalWrite(TFT_RD, HIGH)
	#define WR_ACTIVE    digitalWrite(TFT_WR, LOW)
	#define WR_IDLE      digitalWrite(TFT_WR, HIGH)
	#define CD_COMMAND   digitalWrite(TFT_RS, LOW)
	#define CD_DATA      digitalWrite(TFT_RS, HIGH)
	#define CS_ACTIVE    digitalWrite(TFT_CS, LOW)
	#define CS_IDLE      digitalWrite(TFT_CS, HIGH)
	#define CS_ACTIVE_CD_COMMAND	{ CS_ACTIVE; CD_COMMAND; }
#else
	// use fast bit toggling, very fast speed!
extern gpio_reg_map * cntrlRegs;
	#define RD_ACTIVE				{ cntrlRegs->BRR  = TFT_RD_MASK; }
	#define RD_IDLE					{ cntrlRegs->BSRR = TFT_RD_MASK; }
	#define WR_ACTIVE				{ cntrlRegs->BRR  = TFT_WR_MASK; }
	#define WR_IDLE					{ cntrlRegs->BSRR = TFT_WR_MASK; }
	#define CD_COMMAND				{ cntrlRegs->BRR  = TFT_RS_MASK; }
	#define CD_DATA					{ cntrlRegs->BSRR = TFT_RS_MASK; }
	#define CS_ACTIVE				{ cntrlRegs->BRR  = TFT_CS_MASK; }
	#define CS_IDLE					{ cntrlRegs->BSRR = TFT_CS_MASK; }
	#define CS_ACTIVE_CD_COMMAND	{ cntrlRegs->BRR  = (TFT_CS_MASK|TFT_RS_MASK); }
#endif

#define WR_STROBE { WR_ACTIVE; WR_IDLE; }

extern uint8_t read8_(void);
#define read8(x) ( x = read8_() )

extern gpio_reg_map * dataRegs;

#if defined(TFT_DATA_LOW_NIBBLE)
  //#warning "Using lower data nibble..."
	// set the pins to input mode
	#define setReadDir() ( dataRegs->CRL = 0x88888888 )	// set the lower 8 bits as input
	//#define setReadDir() ( dataRegs->CRL = 0x44444444 )	// set the lower 8 bits as input floating
	// set the pins to output mode
	#define setWriteDir() ( dataRegs->CRL = 0x33333333 )	// set the lower 8 bits as output
	#define TFT_DATA_SHIFT 0
#elif defined(TFT_DATA_HIGH_NIBBLE)
  #warning "Using high data nibble..."
	// set the pins to input mode
	#define setReadDir() ( dataRegs->CRH = 0x88888888 )	// set the upper 8 bits as input
	// set the pins to output mode
	#define setWriteDir() ( dataRegs->CRH = 0x33333333 )	// set the lower 8 bits as output
	#define TFT_DATA_SHIFT 8
#endif

// set pins to output the 8 bit value
#if 0 // slow write
 #define write8(c) { Serial.print(" write8: "); Serial.print(c,HEX); Serial.write(','); \
					digitalWrite(PB0, (c&BIT0)?HIGH:LOW); \
					digitalWrite(PB1, (c&BIT1)?HIGH:LOW); \
					digitalWrite(PB2, (c&BIT2)?HIGH:LOW); \
					digitalWrite(PB3, (c&BIT3)?HIGH:LOW); \
					digitalWrite(PB4, (c&BIT4)?HIGH:LOW); \
					digitalWrite(PB5, (c&BIT5)?HIGH:LOW); \
					digitalWrite(PB6, (c&BIT6)?HIGH:LOW); \
					digitalWrite(PB7, (c&BIT7)?HIGH:LOW); \
					WR_STROBE; }
#else
 #define write8(c) { uint32_t val = (((c^0x00FF)<<16) | c)<<TFT_DATA_SHIFT; \
					/*Serial.print(" write8: "); Serial.print(val,HEX); Serial.write(',');*/ \
					dataRegs->BSRR = val; WR_STROBE; }
#endif

/*****************************************************************************/

#define swap(a, b) { int16_t t = a; a = b; b = t; }

/*****************************************************************************/
// **** IF USING THE LCD BREAKOUT BOARD, COMMENT OUT THIS NEXT LINE. ****
// **** IF USING THE LCD SHIELD, LEAVE THE LINE ENABLED:             ****

//#define USE_ADAFRUIT_SHIELD_PINOUT 1

/*****************************************************************************/
class Adafruit_TFTLCD_8bit_STM32 : public Adafruit_GFX {

 public:

  //Adafruit_TFTLCD_8bit_STM32(uint8_t cs, uint8_t cd, uint8_t wr, uint8_t rd, uint8_t rst);
  Adafruit_TFTLCD_8bit_STM32(void);

  void     begin(uint16_t id = 0x9328);
  void     drawPixel(int16_t x, int16_t y, uint16_t color);
  void     drawFastHLine(int16_t x0, int16_t y0, int16_t w, uint16_t color);
  void     drawFastVLine(int16_t x0, int16_t y0, int16_t h, uint16_t color);
  void     fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t c);
  void     fillScreen(uint16_t color);
  void     reset(void);
  void     setRegisters8(uint8_t *ptr, uint8_t n);
  void     setRegisters16(uint16_t *ptr, uint8_t n);
  void     setRotation(uint8_t x);
       // These methods are public in order for BMP examples to work:
  void     setAddrWindow(int16_t x1, int16_t y1, int16_t x2, int16_t y2);
  void     invertDisplay(boolean i),
			pushColors(uint16_t *data, int16_t len, boolean first),
           drawBitmap(int16_t x, int16_t y, int16_t w, int16_t h, const uint16_t * bitmap);

  uint16_t readPixel(int16_t x, int16_t y),
           readID(void);

 private:

  void     init(),
           // These items may have previously been defined as macros
           // in pin_magic.h.  If not, function versions are declared:
           //setLR(void),
           flood(uint16_t color, uint32_t len);
  uint8_t  driver;
};

extern uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
extern uint16_t readReg(uint8_t r);
extern uint32_t readReg32(uint8_t r);
extern void writeCommand(uint16_t c);
extern void writeRegister8(uint16_t a, uint8_t d);
extern void writeRegister16(uint16_t a, uint16_t d);
extern void writeRegister24(uint16_t a, uint32_t d);
extern void writeRegister32(uint16_t a, uint32_t d);
extern void writeRegisterPair(uint16_t aH, uint16_t aL, uint16_t d);

extern Adafruit_TFTLCD_8bit_STM32 TFT;

#endif


stevestrong
Posts: 1435
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: STM32F103C8 & TFT (ili9325)

Post by stevestrong » Wed Mar 08, 2017 12:56 pm

There is one more thing you should do, adapt the mask bits according to the used port pins for the control lines.
For example, TFT_RD_MASK should be BIT8 if you use PB8, TFT_WR_MASK is BIT9 if you use PB9 and so on (BITX for PBX).

neresus
Posts: 9
Joined: Mon Mar 06, 2017 12:57 am

Re: STM32F103C8 & TFT (ili9325)

Post by neresus » Thu Mar 09, 2017 1:28 pm

stevestrong wrote:There is one more thing you should do, adapt the mask bits according to the used port pins for the control lines.
For example, TFT_RD_MASK should be BIT8 if you use PB8, TFT_WR_MASK is BIT9 if you use PB9 and so on (BITX for PBX).
I try mask bits and it is working. Thank you very much. :D

But after few restarts it stops showing things on display, I do not know why... I try do few more tests what is wrong with stm board.

stevestrong
Posts: 1435
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: STM32F103C8 & TFT (ili9325)

Post by stevestrong » Thu Mar 09, 2017 7:38 pm

Check the reset line.

neresus
Posts: 9
Joined: Mon Mar 06, 2017 12:57 am

Re: STM32F103C8 & TFT (ili9325)

Post by neresus » Thu Mar 09, 2017 10:12 pm

I thing all wires are checked more than good. It is something with stm board. Because LCD is working on UNO.
I can read id of LCD but now is showing nothing.
Is some way to check whole board? I can check pins separately by connecting power on them but if is some other way..

tmk
Posts: 3
Joined: Sun Apr 09, 2017 12:31 pm

STM32 & TFT

Post by tmk » Sun Apr 09, 2017 1:00 pm

Hello User,

I have trouble with a TFT Display: Its that:
"Elegoo 2.8'' TFT Touch Screen - ILI9341"
https://www.elegoo.com/product/elegoo-u ... ch-screen/

The display has 28 Pins. 8 Pins are marked as LCD_D0 to LCD_D7. Then there is LCD_RST, LCD_CS, LCD_RS, LCD_WR and LCD_RD.
3 Pins are for the power 5V, 3.3V and GND. 8 Pins seems to be unused, and there are 4 Pins for and SD Card (SD_SS, SD_DI, SD_DO and SD_SCK)

On an Uno, the display works with the elegoo lib, which is in fact the Adafruit TFT/GFX Lib.
The MCUFRIEND_kbv (Version 2.95? , there is a #define MCUFRIEND_KBV_H_ 295 in the code) also works fine.

When I put the shield on the Uno, I get:

Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 06 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 RDID2 HX8347-G
reg(0x0063) 00 00 RDID3 HX8347-G
reg(0x0064) 00 00 RDID1 HX8347-A
reg(0x0065) 00 00 RDID2 HX8347-A
reg(0x0066) 00 00 RDID3 HX8347-A
reg(0x0067) 00 00 RDID Himax HX8347-A
reg(0x0070) 00 00 Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) 00 00 RGB Interface Signal Control
reg(0x00B4) 00 02 Inversion Control
reg(0x00B6) 00 0A 82 27 04 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 21 00 00 00 00 00 00 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 71 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 03 03 NVM Read
reg(0x00D3) 00 00 93 41 ILI9341, ILI9488
reg(0x00D4) 00 00 00 00 Novatek ID
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 0F 16 14 0A 0D 06 43 75 33 06 0E 00 0C 09 08 GAMMA-P
reg(0x00E1) 00 08 2B 2D 04 10 04 3E 24 4E 04 0F 0E 35 38 0F GAMMA-N
reg(0x00EF) 00 03 80 02 02 02 ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control

I installed STM32Arduino and the board NUCLEO-F103RB.

When I put the display shield on the Nucleo Board, I got:
Read Registers on MCUFRIEND UNO shield
controllers either read as single 16-bit
e.g. the ID is at readReg(0)
or as a sequence of 8-bit values
in special locations (first is dummy)

reg(0x0000) 00 00 ID: ILI9320, ILI9325, ILI9335, ...
reg(0x0004) 00 00 00 00 Manufacturer ID
reg(0x0009) 00 00 61 00 00 Status Register
reg(0x000A) 00 08 Get Power Mode
reg(0x000C) 00 06 Get Pixel Format
reg(0x0061) 00 00 RDID1 HX8347-G
reg(0x0062) 00 00 RDID2 HX8347-G
reg(0x0063) 00 00 RDID3 HX8347-G
reg(0x0064) 00 00 RDID1 HX8347-A
reg(0x0065) 00 00 RDID2 HX8347-A
reg(0x0066) 00 00 RDID3 HX8347-A
reg(0x0067) 00 00 RDID Himax HX8347-A
reg(0x0070) 00 00 Panel Himax HX8347-A
reg(0x00A1) 00 00 00 00 00 RD_DDB SSD1963
reg(0x00B0) 00 00 RGB Interface Signal Control
reg(0x00B4) 00 02 Inversion Control
reg(0x00B6) 00 0A 82 27 04 Display Control
reg(0x00B7) 00 06 Entry Mode Set
reg(0x00BF) 00 00 00 00 00 00 ILI9481, HX8357-B
reg(0x00C0) 00 21 00 00 00 00 00 00 00 Panel Control
reg(0x00C8) 00 00 00 00 00 00 00 00 00 00 00 00 00 GAMMA
reg(0x00CC) 00 71 Panel Control
reg(0x00D0) 00 00 00 Power Control
reg(0x00D2) 00 00 00 03 03 NVM Read
reg(0x00D3) 00 00 93 41 ILI9341, ILI9488
reg(0x00D4) 00 00 00 00 Novatek ID
reg(0x00DA) 00 00 RDID1
reg(0x00DB) 00 00 RDID2
reg(0x00DC) 00 00 RDID3
reg(0x00E0) 00 0F 16 14 0A 0D 06 43 75 33 06 0E 00 0C 09 08 GAMMA-P
reg(0x00E1) 00 08 2B 2D 04 10 04 3E 24 4E 04 0F 0E 35 38 0F GAMMA-N
reg(0x00EF) 00 03 80 02 02 02 ILI9327
reg(0x00F2) 00 02 02 02 02 02 02 02 02 02 02 02 Adjust Control 2
reg(0x00F6) 00 01 00 00 Interface Control

But I totally lost with any other code for the display on STM32. Not a single sketch compiles without errors. (Except the ReadRegisters above)
The example graphictest_kbv from MCUFRIEND gives:
C:\Users\[..]\MCUFRIEND_kbv\utility/mcufriend_shield.h:422:2: error: #error MCU unsupported
#error MCU unsupported

All othe libaries I tried, complain of something in libmaple:
Example:
C:\Users\[..]\Arduino\libraries\Adafruit_ILI9341_8bit_STM\Adafruit_ILI9341_8bit_STM.cpp:9:26: fatal error: libmaple/dma.h: No such file or directory

Now I am clueless. What I'am doing so wrong?

david.prentice
Posts: 107
Joined: Wed Nov 16, 2016 8:52 am

Re: STM32F103C8 & TFT (ili9325)

Post by david.prentice » Sun Apr 09, 2017 2:27 pm

Which STM32 core are you using?
What is the problem with MCUFRIEND_kbv ?

I have just run graphictest_kbv with "Nucleo F103RB" from STM32F1xx Cores by ST-Microelectronics.
And with "STM Nucleo F103RB (STLink)" from the MapleCore by RogerClark et al.

MCUFRIEND_kbv looks for

Code: Select all

defined(ARDUINO_STM_NUCLEO_F103RB) || defined(ARDUINO_NUCLEO_F103RB) 
to tell it which pins to use.

You need v2.9.5-Beta for the cores from ST-Microelectronics
But the v2.9.4 Release should work with the MapleCore.

If you describe your problems, I can probably sort you out.

David.

tmk
Posts: 3
Joined: Sun Apr 09, 2017 12:31 pm

Re: STM32F103C8 & TFT (ili9325)

Post by tmk » Sun Apr 09, 2017 5:34 pm

david.prentice wrote:Which STM32 core are you using?
[..]
You need v2.9.5-Beta for the cores from ST-Microelectronics
But the v2.9.4 Release should work with the MapleCore.

If you describe your problems, I can probably sort you out.
David.
I can only tell you, what I have done:
- Made a fresh installation of Arduino 1.8.2.
- Read https://github.com/stm32duino/wiki/wiki/Boards-Manager for the installation instructions.
- Used as additional board manager URL this: https://github.com/stm32duino/BoardMana ... index.json
- Used "Board Manager" in the Arduino IDE und installed "STM32F1xx Cores by ST Microelectronics Version 2017.1.20"
The comment says: "Included boards Nucleo F103RB"
- Connected the board to the USB port, selected the board in the Arduino IDE and choose the port for uploading.
- Compiled a blink sketch without any error and the sketch worked. Also an Uart example.

And then I connected my TFT display and could not compile anything - but I could when using the Arduino Uno as board.

You said that I need "v2.9.5-Beta". The only "version information" I saw was the date "2017.1.20".
I am using Windows 10, and after the installation of the board I was at first unable to find where the installed files are.
Then I noticed that <User>\APPDATA\local\Arduino15\ was created and there are the dirs "staging" and "packages".
In "packages" there is "STM32" and then "hardware" and "tools". In "hardware" ist "stm32f1" and "stm32f0" and a very deep directory structure.
I never selected any install directory - all was created automatically.

Possibly my build environment is wrong - and I might have no problem with the display or libraries at all?

Can anyone help me to get the newest files? The "v2.9.5-Beta" where is the number and where are the files? ;-)
This maybe a FAQ for all the seasoned STM32 developers here - but my first try was to use the instructions I could get.
Thanks for your time.

david.prentice
Posts: 107
Joined: Wed Nov 16, 2016 8:52 am

Re: STM32F103C8 & TFT (ili9325)

Post by david.prentice » Mon Apr 10, 2017 6:25 am

You are using the core from ST-Microelectronics. View Boards Manager.

Go to the Library Manager. Search for MCUFRIEND_kbv library. The Manager will tell you which version you have installed. e.g. 2.9.4

The Library Manager only installs a Release.
If you want to use a Beta version, you download the ZIP from GitHub. Then install from ZIP.

If I can ever buy a shield with a HX8357-B controller, I will test it and post a new Release.
Buying shields from Ebay is a lottery. You do not know what controller is mounted until the packet arrives. The Ebay Vendors have no idea what they are selling.

David.

stevestrong
Posts: 1435
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: STM32F103C8 & TFT (ili9325)

Post by stevestrong » Mon Apr 10, 2017 7:35 am

neresus wrote:But on your library cannot read LCD id, it return all the time id 0.
That is true.

But I see that your display is probably an ILI9341, see:

Code: Select all

reg(0x00D3) 00 00 93 41 ILI9341, ILI9488
So, if you skip the ID reading and set the identifier to 0x9341, you should be able to build and run the project, and to have something displayed on the screen.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests