Skip to main content
SHong.5
Associate III
November 30, 2020
Solved

Read data in multiple GPIOx_IDR register / Combine GPIO Ports

  • November 30, 2020
  • 5 replies
  • 9123 views

Hi

I'm currently using STM32H743 and I'm trying to Read Data in multiple GPIOx_IDR register

Previously, I was using 16 bits and trying to change into 32 bits for IDR.

When I debug, I could find correct data on SFRs -> Register -> GPIOA -> GPIO_IDR with below code.

previous code

main.h

#define my_data_Pin (0xFFFF) // Use all PA0-PA15 pins

#define my_data_GPIO_Port GPIOA

otherfile.c

void read_my_data(uint16_t *pbuf)

{

*pbuf++ = (uint16_t)my_data_GPIO_Port -> IDR;

}

Now, I'm not sure how to define the code for using all PA0-PA15 pins & PB0-PB15 pins for 32bit data.

 0693W000006E7baQAC.pngI've tried something like below, but it didn't work.

#define my_data_Pin (0xFFFF) && (0xFFFF)

#define my_data_GPIO_Port GPIOA && GPIOB

Could somebody help me out with this please?

Your help will be highly appreciated.

This topic has been closed for replies.
Best answer by TDK
You can read 32 bits at the same time, but only from a single location. You can't read 16 bits from location A and another 16 bits from location B simultaneously.
BSRR always reads as 0, don't see how that would help anything here.

5 replies

TDK
Super User
November 30, 2020

Since your array is of uint16_t, just do two operations:

*pbuf++ = GPIOA->IDR;
*pbuf++ = GPIOB->IDR;

The cast to (uint16_t) isn't hurting anything but it's not necessary.

This will require two operations. Trying to do something like GPIOA && GPIOB is nonsense.

"If you feel a post has answered your question, please click ""Accept as Solution""."
SHong.5
SHong.5Author
Associate III
November 30, 2020

Thank you for your answer

I've tried that, but I want to make it happen simultaneously.

  1. *pbuf++ = GPIOA->IDR;
  2. *pbuf++ = GPIOB->IDR;

#2 is always late than #1.

Currently, I'm using uint32_t instead of uint16_t.

SHong.5
SHong.5Author
Associate III
November 30, 2020

Thank you for your answer

I've tried that, but I want to make it happen simultaneously.

  1. *pbuf++ = GPIOA->IDR;
  2. *pbuf++ = GPIOB->IDR;

#2 is always late than #1.

Currently, I'm using uint32_t instead of uint16_t.

TDK
Super User
November 30, 2020

You can't do them at the same time. The CPU only does one instruction at a time. You could combine them into the same C statement, but it still won't occur at the same time.

*pbuf++ = (GPIOA->IDR << 16) + GPIOB->IDR;

"If you feel a post has answered your question, please click ""Accept as Solution""."
SHong.5
SHong.5Author
Associate III
November 30, 2020

oh... thank you so much for your help.

seems like reading 32bit data at the same time is impossible for STM32H7.

I'm trying BSRR instead of IDR to try 32 bit. However, the data only comes in through IDR register.

TDK
TDKBest answer
Super User
November 30, 2020
You can read 32 bits at the same time, but only from a single location. You can't read 16 bits from location A and another 16 bits from location B simultaneously.
BSRR always reads as 0, don't see how that would help anything here.
"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
November 30, 2020

The FMC could input 32-bit data in parallel on their data inputs, if the used package supports all 32 bits (probably >100 pins); but the latencies may be higher than with GPIO input.

JW

SHong.5
SHong.5Author
Associate III
December 1, 2020

Thank you for your answer

How do you input data to FMC though?

Can't find alternative Ports other than GPIO Ports.

waclawek.jan
Super User
December 1, 2020

Set up FMC for SRAM and perform a read from that "SRAM". You don't need to actually assign pins to address and control lines.

JW