3

I use the STM32 family of microcontrollers, more specifically the STM32F7 series. Currently I'm investigating the use of general-purpose timers.

About double buffered registers.

Microcontrollers sometimes make use of double-buffered registers. In this way, the software can write to and read from the register without causing troubles. The following figure explains:

              buffered register:           active register:
                 --------------             --------------
                |   REGX_BUF   | <-------> |    REGX      |
                 --------------             --------------
                      |                           |
                      |                           |
                   SOFTWARE                    HARDWARE

         The software interacts        Updates to and from the
         only with the buffered        active register take place
         register.                     at specific moments (when it
                                       is 'safe').

         synonyms:                     synonyms:
           - buffered register            - active register
           - preload register
           - shadow register (?)

There are several terms for both REGX_BUF and REGX from the figure above.

  • Usually register REGX is called the "active register".
  • Register REGX_BUF is sometimes called the "buffered register". Other terms are the "preload register" and the "shadow register (?)".

The confusion explained.

Unfortunately there is a confusion about the term "shadow register". From what I read on several sources from the internet, it refers to REGX_BUF. But in the reference manual RM0385 from the STM32F746 microcontroller and RM0410 from the STM32F767 microcontroller I stumble on the exact opposite interpretation of this term "shadow register". It would not refer to REGX_BUF, but rather to REGX.
This is a picture from the reference manual:

RM0385 -> chapter 23 General-purpose timers -> 23.3.2 Counter modes -> Fig 199

or

RM0410 -> Chapter 26 General-purpose timers -> 26.3.2 Counter modes -> Fig 244

enter image description here

This figure confuses me. Do I have a wrong interpretation of the term "shadow register", or is it STMicroelectronics who made an error while writing this reference manual?

K.Mulier
  • 8,069
  • 15
  • 79
  • 141
  • What exactly is the problem? "Shadow register of X" is referring to a register which is "shadowing" or duplicating the value of "X". This diagram is showing that exactly, the shadow register is following the value of the "Auto-preload" one with a little time delay – Eugene Sh. Jan 23 '17 at 18:11
  • From what I read on several sources, "shadow register" is a synonym to "preload register": this is the register interacting with the software. --- The "active register" is the one interacting with the hardware. The figure from the STMicro manual interprets the term "shadow register" not as a synonym to "preload register", but rather a synonym to the "active register". So I'm getting confused. – K.Mulier Jan 23 '17 at 18:15
  • http://electronics.stackexchange.com/questions/86032/what-actually-is-a-shadow-register – Eugene Sh. Jan 23 '17 at 18:16
  • I know, I've read that question. And it is exactly this question that equates the term "shadow register" to "preload register". So that's the opposite of what the STMicro manual is doing. – K.Mulier Jan 23 '17 at 18:17

4 Answers4

6

The problem is that the term "shadow register" does not have a specific and architecture-independent meaning.

For example, the ARM architecture has a set of general purpose registers that you can write to and read from (R0 - R12). However, if you enter the interrupt handler context R8 - R12 are switched to "shadow registers." This means that you still address them like you would in a normal program, but you're accessing completely different registers than the R8 - R12 that you used in the normal program. They're dedicated interrupt handling resources so you don't have to deal with saving and restoring registers like you normally would.

Some PIC microcontrollers allowed you to write to and read from the same address for pin I/O, but in reality, you are writing to a separate buffer than you read from, because writing out to the pins may not necessarily change their state immediately. This configuration allowed the architecture to buffer your write request while it waited until it could change the pin state. These extra buffers are also sometimes called shadow registers, and seems similar to your example. Using the terminology given in your examples, I suppose this would be called a "preload register."

In general, the term is used to refer to multiple hardware resources that you can address the same way. Which one of them is the "real" register and which is the "shadow" register is not consistent across architectures and vendors, and in the end is probably not very important either.

skrrgwasme
  • 9,358
  • 11
  • 54
  • 84
4

Actually ST defines its standard: (p. 14 of General Timer Cookbook)

  • The active register instance (also called the shadow register instance): its content is used by the timer peripheral logic to generate the timer channel outputted waveforms.
  • The preload register instance: this is the register instance accessed by the software when the preload feature of the concerned register is enabled.

the original document is ST AN4776 Application note - that can be found here

1

I have concluded all the above questions and answers: Microcontrollers sometimes make use of double-buffered registers. In this way, the software can write to and read from the register without causing troubles. The following figure explains:

             buffered register:           active register:
             --------------             --------------
            |   REGX_BUF   | <-------> |    REGX      |
             --------------             --------------
                  |                           |
                  |                           |
               SOFTWARE                    HARDWARE

     The software interacts        Updates to and from the
     only with the buffered        active register take place
     register.                     at specific moments (when it
                                   is 'safe').

     synonyms:                     synonyms:
       - buffered register            - active register
       - preload register
       - shadow register (?)

In some manuals, "shadow register" is a synonym to "preload register": this is the register interacting with the software. --- The "active register" is the one interacting with the hardware. The figure from the STMicro manual interprets the term "shadow register" not as a synonym to "preload register", but rather a synonym to the "active register". However, ST defines its standard: (p. 14 of General Timer Cookbook)

  1. The active register instance (also called the shadow register instance): its content is used by the timer peripheral logic to generate the timer channel outputted waveforms.
  2. The preload register instance: this is the register instance accessed by the software when the preload feature of the concerned register is enabled.

So, The problem is that the term "shadow register" does not have a specific and architecture-independent meaning.In general, the term is used to refer to multiple hardware resources that you can address the same way. Which one of them is the "real" register and which is the "shadow" register is not consistent across architectures and vendors, and in the end is probably not very important either.

Narcissus
  • 19
  • 1
  • 1
    Hi Narcissus, thanks for your answer. Since I am not an expert in microcontroller architecture I'm not quite grasping what is unique added in this answer. Perhaps if you highlighted the unique aspect at the top. e.g. "I thought it would be useful to consolidate previous answers into something more understandable." Or "I think previous answers miss a valuable point." – Baron May 12 '21 at 21:12
0

Just to add a bit info, you can find a main curcuit diagram for the Capture/Compare chanel in the reference manual. For example in RM0431 for STM32F72xxx and STM32F73xxx, a diagram which shows the relationship between the preload register and the shadow register for the CCR:

enter image description here

Unfortunately there is not a diagram for ARR, but I think you get the idea.

DingLuo
  • 31
  • 6