2020-11-29 05:08 PM
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.
I'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.
Solved! Go to Solution.
2020-11-29 06:52 PM
2020-11-29 06:10 PM
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.
2020-11-29 06:23 PM
Thank you for your answer
I've tried that, but I want to make it happen simultaneously.
#2 is always late than #1.
Currently, I'm using uint32_t instead of uint16_t.
2020-11-29 06:24 PM
Thank you for your answer
I've tried that, but I want to make it happen simultaneously.
#2 is always late than #1.
Currently, I'm using uint32_t instead of uint16_t.
2020-11-29 06:31 PM
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;
2020-11-29 06:41 PM
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.
2020-11-29 06:52 PM
2020-11-29 06:59 PM
Every GPIO Pins have 16 pins as maximum.
What do you mean, reading 32 bits at the same time is possible?
Do you mean, use only a single pin, instead of 32 pins?
Thanks
2020-11-29 07:06 PM
> What do you mean, reading 32 bits at the same time is possible?
You can read 32 bits at the same time, but you cannot read 32 pin states at the same time, since those bits are not contiguous.
2020-11-29 07:25 PM
Well... I was sending data from other devices to MCU via 16 pins at the same time.
ex) 0000 0000 0000 0101
Then, when I debug, I could read the value 0x101 from below.
SFRs -> Register -> GPIOA -> GPIO_IDR
This kind of process wouldn't be possible for 32 pins, right?