Skip to main content
m-a-c-f
Associate II
December 9, 2024
Question

CHANGE PINS TO IMPUT THEN BACK TO OUTPUT

  • December 9, 2024
  • 1 reply
  • 480 views

 

Hi,

 

I'm trying to read an LCD 8 bits information, so I need to quickly change PA0 ~ PA7 to input, then read the IDR register, and return them to output after reading the 8 bit bus, but I need help.

 

Thank you all.

 

1 reply

MasterT
Lead II
December 9, 2024

Define macros, than call when necessary.

#define setWriteDir() { setReadDir(); \
 GPIOA->MODER |= 0x150000; GPIOB->MODER |= 0x100540; GPIOC->MODER |= 0x4000; }
#define setReadDir() { GPIOA->MODER &= ~0x3F0000; GPIOB->MODER &= ~0x300FC0; GPIOC->MODER &= ~0xC000; }