Where did the BRR go?

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: RoccoMarco, barthess

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Where did the BRR go?

Postby rew » Sat Nov 07, 2020 5:31 pm

I have an application where in an interrupt I need to set and reset GPIOs quickly. When I want to reset bits, I used the BRR (Bit Reset Register).

For example:

Code: Select all

GPIOF->BRR = 1;

Now I've upgraded Chibios and this code no longer compiles. The compiler suggests a different register in the GPIO struct, and searching for that I found the GPIO_TypeDef struct which included that register as well as the BRR on my processor (STM32F030C8T6).

Turns out that:

Code: Select all

#define mGPIOF ((GPIO_TypeDef *)GPIOF)
   mGPIOF->BRR = 1;
Does work.

Why was "normal" access to GPIOF->BRR removed?????

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Where did the BRR go?

Postby Giovanni » Sun Nov 08, 2020 7:20 am

Hi,

The PAL driver uses a different GPIO structure, you need to use the new one. Note that if you use the PAL port/pad functions then you are manipulating the BRR registers with no extra code, it is all inlined, there is no really need to manipulate the register directly.

Giovanni

rew
Posts: 380
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: Where did the BRR go?

Postby rew » Sun Nov 08, 2020 8:57 pm

OK. So in advance, I've prepared the 32-bit word that sets and clears the right bits of that GPIO port when written to the BSRR (A total of precisely 8 bits need to be set and/or reset, the other 8 need to be left alone). Which function helps me do that?

In the documentation I find:

Code: Select all

#define palSetPort   (port,bits )   palWritePort(port, palReadLatch(port) | (bits))
I would say that this will never be able to be merged with a following ClearPort as the "volatile" on the ODR register declaration now requires at least a clock between the the set and clr operations.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Where did the BRR go?

Postby Giovanni » Sun Nov 08, 2020 9:30 pm

You are right, set and clear at same time is not part of the API.

giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 20 guests