cancel
Showing results for 
Search instead for 
Did you mean: 

Can i write to the entire port to data

thannara123
Senior

Hai experts .

Can i wrte data to the  entire Port as follows

GPIOB->ODR |= 0x0000;
HAL_Delay(1000);
GPIOB->ODR |=0xffff;

Whenever i write like wise the SFR register shows correct value in Debug mode 

But in Hardware its not working .whats the wrong with me ?

11 REPLIES 11
AScha.3
Chief III

or 0x0 -> GPIOB->ODR |= 0x0000; = nonsense.

need: GPIOB->ODR &= 0x0000;

If you feel a post has answered your question, please click "Accept as Solution".

which also not working bro

TDK
Guru

> But in Hardware its not working .whats the wrong with me ?

Why don't you think it's working? You are probably misinterpreting something, or there is another issue.

 

If you feel a post has answered your question, please click "Accept as Solution".

Just gives led to the port .not blingking

The clocks for GPIOB need to be enabled, and the pin suitably configured.

You don't show any of that code. Suggest you use libraries until you've got a better mastery of this.

ORing ZERO is not how you clear bits.

You could use ODR or BSRR.  GPIOB->ODR &= ~GPIO_PIN_12; or GPIOB->BSRR = GPIO_PIN_12 << 16; // Clear

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Which STM32 are you actually using? How is the LED wired up? Show a schematic. Show code.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

This code doesn't blink an LED. It does nothing (first line), waits a second then sets all outputs to high.

GPIOB->ODR |= 0x0000;
HAL_Delay(1000);
GPIOB->ODR |=0xffff;

There is no loop which would be needed to blink. It doesn't configure any pins as output which would also be needed to blink an LED. It doesn't configure any ports. It is also missing a second delay, which, if in a loop, would be needed to blink an LED.

Maybe you do these somewhere else in the program, maybe not.

If you feel a post has answered your question, please click "Accept as Solution".
thannara123
Senior

GPIOB->ODR = 0x0000;
HAL_Delay(1000);
GPIOB->ODR = 0xffff;
HAL_Delay(1000);

 

Changed as per above . 

GPIOB perpheral clock enabled ,GPIOB enabled as output .

external 8mhz clock is used . 

In debug mode the ODR 1,2,3 bit of PORT B changing as per programm 

But not refflect in hardware .

I think GPIOB->ODR canot write entire data 

Here can see the data change in ODR regiter 

https://www.kapwing.com/651e24acbc4f1a6b8e3cdf61/studio/editor/sharing