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.
This looks like a code snippet for a STM32 device.
Code Generation ===============
The Keil tools work with STMicroelectronics STM32CubeMX. You can have CubeMX generate the initialization code for you. See:
www.youtube.com/watch
Some Device Family Packs (DFPs) are setup to launch STM32CubeMX from the Manage RTE window:
www.keil.com/.../cubemx_proj.html
That way you can use STM32CubeMX to generate code with the latest versions of their libraries (as the issue updates).
You can also launch STM32CubeMX separately and have it create a uVision5 project.
Code Testing ============= Use the System Viewer Windows to test and verify your settings: www.keil.com/.../uv4_db_dbg_systemviewer.htm
As you debug, these windows get periodically updated with the values on the device. Changing a value in these windows changes the register on the device.
For example open View – System Viewer -> GPIO -> GPIOC
Do the same for the Clock and Peripheral clock registers.
You can play with different GPIO Settings until you get one that works the way you want it to