2016-11-10 12:58 AM
Hello all,
I have a problem that driving me crazy. I'm using STM32F446 with case LQFP64. I'm not able to use PD2 as output digital even if with others PIN I can do it (PC0, PC1, PC2, ...). This is my code to set PD2 as general GPIO output: // LedS - Red GPIOD->MODER = (GPIOD->MODER & 0xFFFFFFCF) | 0x00000010U; GPIOD->OTYPER = (GPIOD->OTYPER & 0xFFFFFFCF); GPIOD->OSPEEDR = (GPIOD->OSPEEDR & 0xFFFFFFCF) | 0x00000030U; GPIOD->PUPDR = (GPIOD->PUPDR & 0xFFFFFFCF); GPIOD->ODR = (GPIOD->ODR & 0xFFFFFFFB);I've attached a LED to this pin, then I try to switch on the led in this way: GPIOD->BSRR = 0x00000010U;Where I'm wrong ? Please help me.Thanks and regards,Enrico. #gpio #stm32f4xx2016-11-10 01:08 AM
Did you activate the clock for GPIO port D ?
And should it not beGPIOD->BSRR = 0x00000004U;
e.g.(1 <<2)2016-11-10 02:53 AM
> GPIOD->OTYPER = (GPIOD->OTYPER & 0xFFFFFFCF);
This is wrong, too, as OTYPER is one bit per pin. Although of no consequence here as the reset value is zero anyway. It's better to use the predefined constants from the basic CMSYS device header, e.g. GPIOD->OTYPER = (GPIOD->OTYPER & (~GPIO_OTYPER_OT_2)); GPIOD->BSRR = GPIO_BSRR_BS_2; etc. JW