Skip to main content
MRoen.1
Associate
January 10, 2021
Solved

Does writing to a port directly (GPIOx->ODR) conflict with fixed hard peripherals on that same port?

  • January 10, 2021
  • 7 replies
  • 1749 views

I'm planning on using a STM32F411CE in an application where the SDIO hard peripheral is connected to a SD-card in 4-bit mode. I also need to use both PA and PB ports in a rather high-speed fashion, so I'd like to set them one 16-bit word at a time (instead of bit-by-bit). If I write a word to say, PB, where bits 4, 5 & 15 are already allocated by the SDIO peripheral, will there be issues? Is there a way to mask off those 3 bits so I won't ruin the SD transfers?

If this specific question is mentioned in any manuals or other places, please point me there. I'm capable of RTFM, I just didn't know where to look. :)

This topic has been closed for replies.
Best answer by waclawek.jan

GPIO chapter of RM and pin AF assignment table in Datasheet.

To have pins assigned to a peripheral, they have to be set as AF in GPIO_MODER. To output value from ODR a different setting, Out, is set in GPIO_MODER.

JW

7 replies

waclawek.jan
waclawek.janBest answer
Super User
January 10, 2021

GPIO chapter of RM and pin AF assignment table in Datasheet.

To have pins assigned to a peripheral, they have to be set as AF in GPIO_MODER. To output value from ODR a different setting, Out, is set in GPIO_MODER.

JW

MRoen.1
MRoen.1Author
Associate
January 10, 2021

Right, so that means, pins that are set as "AF" aren't affected by data written to the ODR. Excellent! That's one thing less to be concerned about. :) Then I can complete the PCB schematic with more confidence. Thanks!

TDK
January 11, 2021

Alternatively, writing to GPIOx->BSRR will let you set or reset only the pins you want without messing with the others.

"If you feel a post has answered your question, please click ""Accept as Solution""."
waclawek.jan
Super User
January 11, 2021

The 'F412 DISCO board features a microSD connector https://www.st.com/en/evaluation-tools/32f412gdiscovery.html so may serve as a test vehicle for initial experiments.

JW

MRoen.1
MRoen.1Author
Associate
January 11, 2021

Excellent tip, thank you Jan!

Now I just have to manage my impulses to refrain from finishing the new PCB, in favour of testing the concept on a proven dev-board, just like a well-behaved engineer is supposed to. Hmm... :smirking_face: We'll see...

waclawek.jan
Super User
January 11, 2021

It's like a textbook: you read it (or maybe even skim through it) it once, when you buy it; then it gathers dust on the shelf until that one day whey you need to look up that particular thing...

JW

Piranha
Principal III
January 13, 2021

Besides datasheet and reference manual, the AN4899 gives additional details on GPIO. :)