Hi, I'm working on a stm32f103 Bluepill trying to drive a 2.4" TFT Display using MCUFFRIEND Library. In mcufriend_shield.h the control and Data pins of the TFT is clearly specified, but unfortunately the data pins are set as PA0 upto PA7 ( for D0 to D7 ).
here's the problem, i need to use 7 ADC input GPIOs in my project for different analog information conversion and in stm32f103 the ADC channels are restricted to pins on Port A. so i tried to change control and data pins specified for stm32 bluepill in the mcufriend_shield.h file as i'm showing here:
this is the original section for bluepill in mcufriend_shield.h:
#define RD_PORT GPIOB
#define RD_PIN 0 //hardware mod to Adapter. Allows use of PB5 for SD Card
#define WR_PORT GPIOB
#define WR_PIN 6
#define CD_PORT GPIOB
#define CD_PIN 7
#define CS_PORT GPIOB
#define CS_PIN 8
#define RESET_PORT GPIOB
#define RESET_PIN 9
//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)
#define setWriteDir() {GP_OUT(GPIOA, CRL, 0xFFFFFFFF); }
#define setReadDir() {GP_INP(GPIOA, CRL, 0xFFFFFFFF); }
first i changed the control pins to check if everything is ok and actually there was no problem and everything was fine:
#define RD_PORT GPIOB
#define RD_PIN 0 //hardware mod to Adapter. Allows use of PB5 for SD Card
#define WR_PORT GPIOB
#define WR_PIN 6
#define CD_PORT GPIOB
#define CD_PIN 7
#define CS_PORT GPIOC
#define CS_PIN 13
#define RESET_PORT GPIOC
#define RESET_PIN 14
then to be able to use Port A for ADC operations, i changed the Data pins from B8 upto B15 like this:
#define write_8(d) { GPIOB->REGS(BSRR) = 0xFF000000 ; GPIOB->REGS(BSRR) = (d<<8) & 0x0000FF00; }
#define read_8() ((GPIOB->REGS(IDR) & 0xFF00)>>8)
#define setReadDir() {GP_INP(GPIOB, CRH, 0xFFFFFFFF); }
#define setWriteDir() {GP_OUT(GPIOB, CRH, 0xFFFFFFFF); }
but as i change the data pins, it doesn't anymore.
is there any problem with changing the data pins?
did i make any mistake in the process of data pins change?
i would be really thankful if somebody give me an advice.