STM32 Unused Space - Rules?

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,615
Does anyone know if the STM32 documentation mentions how to treat unused space, consider the GPIO layout:

1707511345610.png

Each GPIO is a set of registers, and the entire set does not occupy 1K yet each GPIO is aligned on a 1K boundary, so there is unused memory between the end of one GPIO register set and the start of the next.

I fully expect that memory to be avoided, never accessed by our code but the issue seems to not be mentioned anywhere, does anyone know about this?
 

MrChips

Joined Oct 2, 2009
30,820
The unused space is not memory. It has been assigned to hardware modules, in this case, the GPIO module. You don't want to access undocumented addresses.
 

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,615
The unused space is not memory. It has been assigned to hardware modules, in this case, the GPIO module. You don't want to access undocumented addresses.
I imagine this allows for expansion in the future, but was curious if the official documentation calls this out, as you say we do NOT want to read/write these address ranges.
 

Papabravo

Joined Feb 24, 2006
21,225
I have not looked at the official documentation, but in similar circumstances you might find some or all of the following:
  1. The processor throws an exception (interrupt or trap) when unallocated memory is accessed. The exception (interrupt ) processing service routine can record information about the culprit so the source can be identified.
  2. A read to unallocated memory returns the constant value of an undriven bus. This will usually be all zeros or all ones.
  3. A write to an unallocated location could be treated as a NOP since no other processor registers are affected.
In the case that the processor has an exception handling mechanism, one useful purpose would be to use it as a software interrupt. If you know what that is and how useful they are, then good on you. The location you access could even be an argument to the software interrupt.

There may be other implications but none of them occur to me at the moment.

On the 8051 architecture my preferred method for creating a software interrupt, was to set a counter to overflow after one count and write a macro that would enable the counter interupt disguised to look like the invocation of the SWI() function. The service routine would do its thing, reload the counter for one count, disable the counter interrupt and exit.
 
Last edited:

Thread Starter

ApacheKid

Joined Jan 12, 2015
1,615
I just tested this and on STM32 (at least the F407 I'm using) the memory is unwritable, writing a value has no effect. The memory is all zeros and remains all zeros after the write.
 

Papabravo

Joined Feb 24, 2006
21,225
I just tested this and on STM32 (at least the F407 I'm using) the memory is unwritable, writing a value has no effect. The memory is all zeros and remains all zeros after the write.
Did you look in the documentation to see if there was an exception, trap, interrupt for unused memory access. The reason your experiment might not have triggered it is that it might need to be enabled.
 
Top