Adafruit ILI9341_8bit_STM

Post Reply
Leplouc
Posts: 14
Joined: Fri Nov 10, 2017 12:31 pm
Location: Toulouse France

Adafruit ILI9341_8bit_STM

Post by Leplouc » Fri Nov 10, 2017 8:31 pm

Many hours spent to match my ST32F103T8C6 and 8 bit 3.5' TFT display but it works...!
I simply changed the initial 320x240 with 480x320 in the library .h
By the way, the 8 bits configuration is quite port consuming and I have to managed the rest of my hardware considering the remaining Port.
The 8 bits of DATA are send from PORT A (0-7).
I have a couple à buttons to test in my main loop and i plan to attached them to PORTA using input_PULLUP.
Unfortunatly, PORT A (8-15) doesnt not provide any voltage when PULLUP is declared, the PORT is really in input and works ok with external PU resistors.
If I try to use PORT A (PULLUP) without the Adafruit library, everything is ok and voltage are present on PORT A (8-15). So, obviously the problem comes from the library.
I tried to find out if by any chance I can locate something which could disable the PULLUP fonction but I am not good enough..(in .ccp especially).
Help is welcome and sorry for my english.

User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Adafruit ILI9341_8bit_STM

Post by Pito » Fri Nov 10, 2017 9:48 pm

Could you post a link to that library, plz?
Pukao Hats Cleaning Services Ltd.

Leplouc
Posts: 14
Joined: Fri Nov 10, 2017 12:31 pm
Location: Toulouse France

Re: Adafruit ILI9341_8bit_STM

Post by Leplouc » Sat Nov 11, 2017 6:29 am


User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Adafruit ILI9341_8bit_STM

Post by Pito » Sat Nov 11, 2017 8:14 am

Most probably you have to add the

Code: Select all

regs->PUPDR
pull-up/pull-down GPIO setting inside all the functions which mess with Port A - like:

Code: Select all

void Adafruit_ILI9341_8bit_STM::setReadDataBus(void) {
  TFT_DATA->regs->CRL = 0x88888888;
  TFT_DATA->regs->PUPDR = 0x55550000;    // << SET PULL-UPs on PA15-PA8
 }
such the pull-ups stay active all the time..
Not tested..
Pukao Hats Cleaning Services Ltd.

Leplouc
Posts: 14
Joined: Fri Nov 10, 2017 12:31 pm
Location: Toulouse France

Re: Adafruit ILI9341_8bit_STM

Post by Leplouc » Sat Nov 11, 2017 8:39 am

Thanks,
This code inside the .cpp file or inside setup ?

I tried to insert in the .cpp file :
TFT_DATA->regs->CRL = 0x88888888; (already exist)
TFT_DATA->regs->PUPDR = 0x55550000;
Compilation says :
libraries\Adafruit_ILI9341_8bit_STM\Adafruit_ILI9341_8bit_STM.cpp:47:19: error: 'gpio_reg_map' has no member named 'PUPDR'

User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: Adafruit ILI9341_8bit_STM

Post by Pito » Sat Nov 11, 2017 9:54 am

Well, it seems the register is not defined in libmaple (gpio_reg_map).
You may set the pullups individually as well

Code: Select all

pinMode(PA8, INPUT_PULLUP);
pinMode(PA9, INPUT_PULLUP);
..
pinMode(PA15, INPUT_PULLUP);
inside the functions inside the .cpp file as a quick proof of concept.

PS:
Try

Code: Select all

void Adafruit_ILI9341_8bit_STM::setReadDataBus(void) {
  TFT_DATA->regs->CRL = 0x88888888;
  TFT_DATA->regs->CRH = 0x88888888; // <<  SET INPUT W/ PUPD on PA15-PA8    
  TFT_DATA->regs->ODR = 0x0000FF00; // <<  SET PULL-UPs on PA15-PA8
 }
My current understanding is as follows:

CRL = 0x88888888 sets PA0-PA7 to input with PULLUP/PULLDOWN option,
CRH = 0x88888888 sets PA15- PA8 to input with PULLUP/PULLDOWN option,

and when set to input with PULLUP/PULLDOWN option the actuall PULLUP or PULLDOWN at the particular pin is set by ODR, where 0 sets PULLDOWN and 1 sets PULLUP, ie.:

ODR = 0x0000FF00 sets PA0-PA7 pulldown and PA15-PA8 pullup
ODR = 0x000000FF sets PA0-PA7 pullup and PA15-PA8 pulldown
Pukao Hats Cleaning Services Ltd.

Leplouc
Posts: 14
Joined: Fri Nov 10, 2017 12:31 pm
Location: Toulouse France

Re: Adafruit ILI9341_8bit_STM

Post by Leplouc » Sat Nov 11, 2017 2:44 pm

It's the same and nu pullup anymore..
Well, I have an other constrain concerning I2C.
I want to drive a Si5351 board and I tried to use SDA2 and SCL2 without any success (using Wire2 and also HWrite).
So I plan to swap PB4----PB8 actully used for CTRL TFT to PA8---PA12.
I have already tried to modify both the .h and .ccp files but in vain..

.h file :

Code: Select all

//Port data |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
//Pin stm32 |PA7|PA6|PA5|PA4|PA3|PA2|PC1|PA0|
//Control pins |RD |WR |RS |CS |RST|
//Pin stm32    |PB4|PB5|PB6|PB7|PB8| now PA8---PA12 
#define TFT_CNTRL      GPIOA
#define TFT_DATA       GPIOA
#define TFT_RD         PA8
#define TFT_WR         PA9
#define TFT_RS         PA10
#define TFT_CS         PA11
#define TFT_RST        PA12
#define TFT_RD_MASK    digitalPinToBitMask(TFT_RD)
#define TFT_WR_MASK    digitalPinToBitMask(TFT_WR)
#define TFT_RS_MASK    digitalPinToBitMask(TFT_RS)
#define TFT_CS_MASK    digitalPinToBitMask(TFT_CS)
.ccp file :

Code: Select all

// Constructor when using 8080 mode of control.
Adafruit_ILI9341_8bit_STM::Adafruit_ILI9341_8bit_STM(void)
: Adafruit_GFX(ILI9341_TFTWIDTH, ILI9341_TFTHEIGHT) {
  
  //Set PB4 - PB7 as output (now PA8--PA12
  //Note: CRH and CRL are both 32 bits wide
  //Each pin is represented by 4 bits 0x3 (hex) sets that pin to O/P
  TFT_CNTRL->regs->CRH = (TFT_CNTRL->regs->CRH & 0xFFFF0000) | 0x00003333;
    CS_IDLE; // Set all control bits to HIGH (idle)
    CD_DATA; // Signals are ACTIVE LOW
    WR_IDLE;
    RD_IDLE;
  if(TFT_RST) {
    //pinMode(TFT_RST, OUTPUT);
    //Set PB8 as output (now PA12)
    TFT_CNTRL->regs->CRH = (TFT_CNTRL->regs->CRH & 0xFFF0FFFF) | 0x00030000; 
    digitalWrite(TFT_RST, HIGH);
  }
Unfortunatly the TFT screen stays black..

Post Reply