AnsweredAssumed Answered

Noob question on ports

Question asked by n.neil on Oct 4, 2015
Latest reply on Apr 1, 2018 by Clive One
Hi all,

Just plunging in again to learn STM32/ARM coding, and have a GPIO issue (on a STM32L100C discovery board):

Why does this work...
GPIOC->MODER |= (GPIO_MODER_MODER8_0 | GPIO_MODER_MODER9_0) ;
GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_8 | GPIO_OTYPER_OT_9) ;
GPIOC->OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR8|GPIO_OSPEEDER_OSPEEDR9);
GPIOC->PUPDR &= ~(GPIO_PUPDR_PUPDR8|GPIO_PUPDR_PUPDR9);
 
while(1)
{
    GPIOC->ODR = 0x0300;
    delay(10000);
    GPIOC->ODR = 0x0300;
    delay(10000);
}


But not this?...
    GPIOC->MODER |= (GPIO_MODER_MODER8_0 | GPIO_MODER_MODER9_0) ;
    GPIOC->OTYPER &= ~(GPIO_OTYPER_OT_8 | GPIO_OTYPER_OT_9) ;
    GPIOC->OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR8|GPIO_OSPEEDER_OSPEEDR9);
    GPIOC->PUPDR &= ~(GPIO_PUPDR_PUPDR8|GPIO_PUPDR_PUPDR9);
 
    while(1)
    {
        GPIOC->BSRR = 0x0300;
        delay(10000);
//      GPIOC->BSRR = 0x0300;       // This also did not work
        GPIOC->BRR = 0x0300;
        delay(10000);
    }

Outcomes