cancel
Showing results for 
Search instead for 
Did you mean: 

trying to read 8 bit port reading and writing . it's working but it's correct?? uint8_t pins = GPIOA->IDR; if(pins == 0xFF){ GPIOC->ODR=0xF000; } else { GPIOC->ODR=0x0000; }

MMARI.1
Senior
 
3 REPLIES 3

"Correct" depends on context.

Generally, it's better to change output pins using the GPIOx_BSRR register, as it changes only those pins which you intend to change, leaving others untouched. But if you always change all output pins of one GPIO at once, using ODR is OK.

JW

S.Ma
Principal

Use BSRR to get the right way before implementing niche situations that won't likely copy paste next time. While not perfect, check HAL_GPIO functions to get familiar with interacting with HW registers. Then think multitask, interrupt, shared HW registers, volatility....

MMARI.1
Senior

hi, i have checked BSRR .

16bit & 32bit

GPIOB->ODR = 0xFFFF; and GPIOB->BSRR = 0x0000FFFF; what is exact difference . which is faster .

which one deliver as parallels port output data .

correct me if i understood wrong .