cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 code break after upgrading from 1.3.0 to 1.5.0 Firmware package

embedonix
Associate III

My STM32H7 firmware was working and compiling fine before I upgrade my CubeMX firmware package from 1.3.0 to 1.5.0.

It seems that the GPIO register struct has been changed and "BSRRH" and "BSRRL" members of the struct do not exist anymore! So my code does not compile! What should I do? E.g. code below:

CTRL_N3_GPIO_Port->BSRRL = CTRL_N1_Pin; // SET
CTRL_N3_GPIO_Port->BSRRH = CTRL_N2_Pin; // RESET

The error is:

Field 'BSRRH' could not be resolved main.c

The struct now only offers "BSRR". How can I solve this problem and why even such major changed made its way into this patch?

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel A.
Evangelist III

CTRL_N3_GPIO_Port->BSRR = (uint16_t)CTRL_N1_Pin; // SET

CTRL_N3_GPIO_Port->BSRR = (uint16_tCTRL_N2_Pin << 16; // RESET

> why even such major changed made its way into this patch?

Maybe 16-bit accesses to high and low parts of BSRR do not work in some cases. 32-bit access always works.

1.5.0 is not a patch, btw, it is a major version. Patches are denoted by the 3rd number (Z in X.Y.Z).

-- pa

View solution in original post

3 REPLIES 3
Pavel A.
Evangelist III

CTRL_N3_GPIO_Port->BSRR = (uint16_t)CTRL_N1_Pin; // SET

CTRL_N3_GPIO_Port->BSRR = (uint16_tCTRL_N2_Pin << 16; // RESET

> why even such major changed made its way into this patch?

Maybe 16-bit accesses to high and low parts of BSRR do not work in some cases. 32-bit access always works.

1.5.0 is not a patch, btw, it is a major version. Patches are denoted by the 3rd number (Z in X.Y.Z).

-- pa

Thanks Pavel.

I knew the solution is to shift bits. My point was how to do it in the struct to fix it in one place only (I have hundreds of BSRRX in my code).

But now that you say it is a major release then I will revert back to 1.3.Z and save myself some time :))

Piranha
Chief II

This is why people create and use APIs. Even, when not using functions, at least make some simple macros. For example:

  • PIN_SET(CTRL_N3_GPIO_Port, CTRL_N1_Pin);
  • PIN_RESET(CTRL_N3_GPIO_Port, CTRL_N2_Pin);

You'll be able to change macro's underneath functionality easily and not need those code comments anymore, as macro's name already says what it does.