STM32F103C8 & TFT (ili9325)

Working libraries, libraries being ported and related hardware
Post Reply
stevestrong
Posts: 1813
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: STM32F103C8 & TFT (ili9325)

Post by stevestrong » Wed Nov 23, 2016 3:53 pm

mausi_mick wrote:compile and upload ? without error,
but no info on the serial monitor.
Ok, it seems that I misunderstood your post, I though you dont have any serial output at all.
In the case you can output info on serial monitor, then please USE DAVIDs SKETCH!!!
Last edited by stevestrong on Wed Nov 23, 2016 3:55 pm, edited 2 times in total.

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

Re: STM32F103C8 & TFT (ili9325)

Post by david.prentice » Wed Nov 23, 2016 3:54 pm

The first job is to get your Serial working. A Maple Mini must have one USART for comms through USB.
Alternatively, you attach a USART-USB dongle to any of the 3 USARTs that seem to have 7 sets of hardware pins. (you probably don't have all 7 on your MCU)

Having got the Serial working, you connect your Shield. And edit the readreg sketch to match your wiring.

Until you can produce a good readreg output, we will not have any confidence in your wiring.
And if you have never used "Serial", the exercise will be invaluable to you.

David.

mausi_mick
Posts: 148
Joined: Fri Aug 12, 2016 1:40 pm

Re: STM32F103C8 & TFT (ili9325)

Post by mausi_mick » Wed Nov 23, 2016 4:12 pm

I think I have to read the register in the loop().

It was a good idea:
LCD_ID_register_Maple_mini.jpg
LCD_ID_register_Maple_mini.jpg (192.35 KiB) Viewed 423 times

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

Re: STM32F103C8 & TFT (ili9325)

Post by david.prentice » Wed Nov 23, 2016 5:04 pm

That verifies your wiring. Is it the same as you posted earlier?

If not, please post the actual #defines that gave the good output.

David.

mausi_mick
Posts: 148
Joined: Fri Aug 12, 2016 1:40 pm

Re: STM32F103C8 & TFT (ili9325)

Post by mausi_mick » Wed Nov 23, 2016 5:29 pm

Hi David,

in the register_id sketch I have this defines:

Code: Select all

//-- Arduino UNO or Mega 2560 Plugged as shield
//              maple    UNO   maple
//              port     Pin   Pin    
#define LCD_CS  PB14  // A3    29
#define LCD_RS  PB5   // A2    17
#define LCD_RST PB15  // A4    28
#define LCD_WR  PB4   // A1    18
#define LCD_RD  PB3   // A0    19

#define LCD_D0  PA0   // 8     11  
#define LCD_D1  PA1   // 9     10
#define LCD_D2  PA2   // 2      9
#define LCD_D3  PA3   // 3      8    
#define LCD_D4  PA4   // 4      7
#define LCD_D5  PA5   // 5      6
#define LCD_D6  PA6   // 6      5
#define LCD_D7  PA7   // 7      4
in the ...8bit.h this defines:

Code: Select all

/*****************************************************************************/
// Define pins and Output Data Registers
/*****************************************************************************/

#define TFT_DATA       GPIOA                         // orig. GPIOB  ############################
// Port data bits D0..D7:
// enable only one from below lines corresponding to your HW setup:
#define TFT_DATA_NIBBLE	0 // take the lower 8 bits: 0..7
//#define TFT_DATA_NIBBLE	8 // take the higher 8 bits: 8..15

//Control pins |RD |WR |RS |CS |RST|
define TFT_CNTRL      GPIOB      //   

#define TFT_RD   PB3   // A0    19
#define TFT_WR   PB4   // A1    18
#define TFT_RS   PB5   // A2    17
#define TFT_CS   PB14  // A3    29
#define TFTR_RST PB15  // A4    28

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

Re: STM32F103C8 & TFT (ili9325)

Post by stevestrong » Wed Nov 23, 2016 6:14 pm

As far as I can see, the ID of 0x9327 is contained in the register 0xEF.
The reading of this register is not implemented in my version, that's why you get as ID the value 0.
You should try to force the ID as being the value 0x9325, and use this value when calling begin() in your sketch.

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

Re: STM32F103C8 & TFT (ili9325)

Post by david.prentice » Wed Nov 23, 2016 6:21 pm

Please install the v2.9.1-Beta MCUFRIEND_kbv library from GitHub.

Then add this conditional block:

Code: Select all

#elif defined(__STM32F1__) && defined(ARDUINO_MAPLE_MINI) // Uno Shield on MAPLE_MINI board
#warning Uno Shield on MAPLE_MINI for MAUSI_MICK
// be wise to clear all four mode bits properly.
#define GROUP_MODE(port, reg, mask, val)  {port->regs->reg = (port->regs->reg & ~(mask)) | ((mask)&(val)); }
#define GP_OUT(port, reg, mask)           GROUP_MODE(port, reg, mask, 0x33333333)
#define GP_INP(port, reg, mask)           GROUP_MODE(port, reg, mask, 0x44444444)

#define RD_PORT GPIOB
#define RD_PIN  3
#define WR_PORT GPIOB
#define WR_PIN  4
#define CD_PORT GPIOB
#define CD_PIN  5
#define CS_PORT GPIOB
#define CS_PIN  14
#define RESET_PORT GPIOB
#define RESET_PIN  15

// configure macros for the data pins
#define write_8(d) { GPIOA->regs->BSRR = 0x00FF << 16; GPIOA->regs->BSRR = (d) & 0xFF; }
#define read_8() (GPIOA->regs->IDR & 0xFF)
//                                         PA7 ..PA0
#define setWriteDir() {GP_OUT(GPIOA, CRL, 0xFFFFFFFF); }
#define setReadDir()  {GP_INP(GPIOA, CRL, 0xFFFFFFFF); }

#define write8(x)     { write_8(x); WR_ACTIVE; WR_STROBE; }
#define write16(x)    { uint8_t h = (x)>>8, l = x; write8(h); write8(l); }
#define READ_8(dst)   { RD_STROBE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; RD_ACTIVE; dst = read_8(); RD_IDLE; }
#define READ_16(dst)  { uint8_t hi; READ_8(hi); READ_8(dst); dst |= (hi << 8); }

#define PIN_HIGH(port, pin)   (port)->regs->BSRR = (1<<(pin))
//#define PIN_LOW(port, pin)    (port)->regs->BSRR = (1<<((pin)+16))
#define PIN_LOW(port, pin)    (port)->regs->ODR &= ~(1<<(pin))
// ######### changed the PIN_OUTPUT() macro ###############################################
#define PIN_OUTPUT(port, pin) gpio_set_mode(port, pin, GPIO_OUTPUT_PP)   //50MHz push-pull only 0-7
#define PIN_INPUT(port, pin)  gpio_set_mode(port, pin, GPIO_INPUT_FLOATING)   //digital input 
// ######################################################################################
The macro expansions produce masses of Warnings. This is all down to your choice of PB14, PB15 as control pins. And I had to produce a horrible kludge in the PIN_OUTPUT() macro.

Either put the sequence in mcufriend_special.h (define USE_SPECIAL in mcufriend_shield.h)
Or put it directly in mcufriend_shield.h (but please do not distribute the file)

Run the graphictest_kbv sketch. It should read the ID correctly to the Serial Terminal.
And hopefully produce a graphic displAY.

David.
Last edited by david.prentice on Wed Nov 23, 2016 8:07 pm, edited 1 time in total.

mausi_mick
Posts: 148
Joined: Fri Aug 12, 2016 1:40 pm

Re: STM32F103C8 & TFT (ili9325)

Post by mausi_mick » Wed Nov 23, 2016 7:20 pm

david ,

is the 2.9.1 the last version?

I have installed it ... /hardware .../STM32F1/lib.../MCU..._kbv

But I have problems compiling the sketch , a lot of errors !

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

Re: STM32F103C8 & TFT (ili9325)

Post by david.prentice » Wed Nov 23, 2016 7:48 pm

You need the current GitHub. I only received my NUCLEO board last week. The STM32 support is only tested on the Nucleo.

The IDE should install the Library from the ZIP into your regular Arduino libraries not into STM32.

The Orange output is basically Warnings. It should compile ok. I use v1.6.12 IDE and the ARM tools are 4.8.3-2014q1

I will post you a different PIN_OUTPUT() macro which should support the CRH register but without the Warnings.

David.

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

Re: STM32F103C8 & TFT (ili9325)

Post by david.prentice » Wed Nov 23, 2016 8:09 pm

I have edited the earlier post. i.e. changed the macros to use the libmaple function:

Code: Select all

#define PIN_OUTPUT(port, pin) gpio_set_mode(port, pin, GPIO_OUTPUT_PP)   //50MHz push-pull only 0-7
#define PIN_INPUT(port, pin)  gpio_set_mode(port, pin, GPIO_INPUT_FLOATING)   //digital input 
This should avoid the horrible Warnings but obviously relies on any STM32 builds using libmaple.

David.

Post Reply