We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello) Please, tell me what I'm doing wrong. I want to make the LED (PE1) work when the (PB13) button is pressed, but it does not work, as I understand that I am not correctly initializing the mode of the button port, there must be Input mode, but I don’t understand how to do it. I just have an LED on, but nothing happens when the button is pressed. My board is stm32h743zi. Can you please tell me what I'm doing wrong, I checked all the sites, but I couldn't find anything. p.s. I tried to write the same thing through HAL, everything naturally works there, but I want to understand how to work with a button without HAL.
#include "stm32h7xx.h"
void GPIO_Init(void);
int main(void) {
GPIO_Init();
if((GPIOC->IDR & GPIO_IDR_ID13) != 0) {
GPIOE->BSRR |= GPIO_BSRR_BR1;
}else{
GPIOE->BSRR |= GPIO_BSRR_BS1;
}
void GPIO_Init ()
{
RCC->AHB4ENR |= RCC_AHB4ENR_GPIOEEN;
RCC->AHB4ENR |= RCC_AHB4ENR_GPIOCEN;
GPIOE->MODER = GPIO_MODER_MODE1_0;
GPIOC->MODER &= ~GPIO_MODER_MODE13;