cancel
Showing results for 
Search instead for 
Did you mean: 

mistake in stm32f4xx.h

konstantin
Associate II
Posted on November 16, 2013 at 17:31

to be migrated, sourceId: 35463:697285D7-A9CA-445D-B16C-F23BF0E3B1A3

#stm32f4
4 REPLIES 4
Posted on November 16, 2013 at 18:58

The application of the defines would be for a 32-bit cast of the register. ie *((uint32_t *)&GPIOx->BSRRL) = Mask; // Set and Reset combined

You don't read-modify-write the register (|=), the purpose is to do a single atomic write, logic behind the peripheral register handles the current settings of the ODR.

Thus

GPIOD->BSRRL = GPIO_Pin_12;

GPIOD->BSRRH = GPIO_Pin_12;

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
konstantin
Associate II
Posted on November 16, 2013 at 19:09

So where is the definition of the mask 

GPIO_Pin_12? if i don't want to use StandardPeriferalLibrary.

konstantin
Associate II
Posted on November 16, 2013 at 19:16

I said that GPIOD->BSRRH = GPIO_BSRR_BR_12 doesn't works. So there is maybe mistake in definitions of BR masks in the stm32f4xx.h.  __IO uint16_t BSRRH and #define GPIO_BSRR_BR_12  ((uint32_t)0x10000000) . writing word (uint32_t) into halfword (uint16_t) has no effect.

Posted on November 17, 2013 at 00:33

Thus the use of the cast.

In other series parts a 32-bit BSRR is used, here it's split in Low and High portions, separating the set/reset halves.

Pin 12 being (1 << 12), GPIO_Pin_12 is defined in stm32f4xx_gpio.h
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..