This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

settin up pins and reading them

I'm not able to set up my input and read the condition using hall.

I want to pull in and hold high (internal pull up) 3 pins. Then simply read the condition.

This is how I set them up, left comments, did I do this right?

GPIOC->MODER &= ~(GPIO_MODER_MODER6_0);//in
GPIOC->OSPEEDR &= ~GPIO_OSPEEDER_OSPEEDR6;//set max speed
GPIOC->OTYPER &= ~GPIO_OTYPER_OT_6;//push pull mode
//GPIOC->PUPDR &= ~GPIO_PUPDR_PUPDR6 ;//disable pull up down.
GPIOC->BSRR &= ~(1<<6);GPIOC->BSRR |= (1<<22);//hold high

GPIOC->MODER &= ~(GPIO_MODER_MODER7_0);//in
GPIOC->OSPEEDR &= ~GPIO_OSPEEDER_OSPEEDR7;//set max speed
GPIOC->OTYPER &= ~GPIO_OTYPER_OT_7;//push pull mode
//GPIOC->PUPDR &= ~GPIO_PUPDR_PUPDR7 ;//disable pull up down.
GPIOC->BSRR &= ~(1<<7);GPIOC->BSRR |= (1<<23); //hold high

GPIOC->MODER &= ~(GPIO_MODER_MODER8_0);//in
GPIOC->OSPEEDR &= ~GPIO_OSPEEDER_OSPEEDR8;//set max speed
GPIOC->OTYPER &= ~GPIO_OTYPER_OT_8;//push pull mode
//GPIOC->PUPDR &= ~GPIO_PUPDR_PUPDR8 ;//disable pull up down.
GPIOC->BSRR &= ~(1<<8);GPIOC->BSRR |= (1<<24);//hold high

then I just watch GPIOC->IDR but it's always 0x0000ffff no matter the condition of the pin.

Parents
  • GPIOC->OSPEEDR &= ~GPIO_OSPEEDER_OSPEEDR6;//set max speed ACTUALLY SLOWEST, BUT AN INPUT, WHO CARES
    Make sure you've enable the GPIO clocks, and check the peripheral setting via the debugger's peripheral view. If all GPIO registers stuck at ZERO, clock probably not enabled.

Reply
  • GPIOC->OSPEEDR &= ~GPIO_OSPEEDER_OSPEEDR6;//set max speed ACTUALLY SLOWEST, BUT AN INPUT, WHO CARES
    Make sure you've enable the GPIO clocks, and check the peripheral setting via the debugger's peripheral view. If all GPIO registers stuck at ZERO, clock probably not enabled.

Children