cancel
Showing results for 
Search instead for 
Did you mean: 

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

MRoen.1
Associate II

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. :)

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

7 REPLIES 7

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
Associate II

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
Guru

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".

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
Associate II

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...

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
Chief II

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