2021-02-20 09:27 AM
Hello everyone,
I would like to know how to read data from pin on STM32F4. I have a small project where I am blinking led (it's running throw Arduino board) and I would like to see throw STM32F4 when it's on and when it isn't. How should I setup pin? GPIO_INPUT or GPIO_ANALOG? I am new to programming so I am sorry for my question. I would like to create something like a simple logic analyzer so I could see in debug the logic of led. I would like to have something whats on the picture I attached. Thanks for any help.
2021-05-24 02:04 AM
Hello TrixCZE,
Reading GPIO state can be achieved reading the IDR register input data register of the GPIO port your application is using.
You can refer to AN4899 - STM32 GPIO configuration for hardware settings and low-power consumption
Regards,
Simon
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2021-05-24 02:14 AM
What do you mean by reading pin here and who is reading?
If you meant for CPU to read the register value associated with the GPIO port, in this case you would need to setup your pin as output as you need it to drive the external LED. Then consult the data sheet to know the register address of the GPIO and then you can read it in your code. To toggle the LED, you simply toggle 1 and 0 to the register. Hope it helps