2017-06-25 11:53 PM
I asked this quiestion yesterday and for some reason I do not see it in the forum ans also did not got any email about it.
I want to Set/Reset 6 GPIO pins belong to the same port using HAL what I am doing now is calling HAL_GPIO_WritePin 6 times which take too much time how can I do it it one command.since all pins are of the same port.
#gpio2017-06-26 12:10 AM
You can write GPIOx_BSRR with a 32-bit value in a single step - the lower 16-bit for those bits which have to be set and the upper 16-bit for those which have to be cleared. This is a perfectly atomic operation. See GPIO chapter in RM. I don't know if this has some name in Cube's.
JW
2017-06-26 12:26 AM
Hi,
You can set all pins you want at one function call and reset another pins at one function call like this:
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6, GPIO_PIN_RESET);
Bests,Misagh