3

我使用 STM32 系列微控制器,更具体地说是该STM32F7系列。目前我正在研究通用计时器的使用。

关于双缓冲寄存器。

微控制器有时会使用双缓冲寄存器。这样,软件就可以对寄存器进行写入和读取,而不会造成麻烦。下图说明:

              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 (?)

两者都有几个术语REGX_BUFREGX从上图中可以看出。

  • 通常寄存器REGX被称为“活动寄存器”。
  • 寄存器REGX_BUF有时被称为“缓冲寄存器”。其他术语是“预加载寄存器”和“影子寄存器 (?)”。

混乱解释了。

不幸的是,“影子寄存器”一词令人困惑。根据我从互联网上的几个来源阅读的内容,它指的是REGX_BUF. 但在 STM32F746 微控制器的参考手册 RM0385 和 STM32F767 微控制器的 RM0410 中,我偶然发现了对“影子寄存器”这个术语的完全相反的解释。它不会指代REGX_BUF,而是指代REGX
这是参考手册中的图片:

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

或者

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

在此处输入图像描述

这个数字让我很困惑。是我对“影子寄存器”一词的错误解释,还是意法半导体在编写本参考手册时犯了错误?

4

3 回答 3

6

问题是术语“影子寄存器”没有特定的和架构独立的含义。

例如,ARM 架构有一组通用寄存器,您可以写入和读取 (R0 - R12)。但是,如果进入中断处理程序上下文,R8 - R12 会切换到“影子寄存器”。这意味着您仍然可以像在普通程序中一样对它们进行寻址,但是您访问的寄存器与您在普通程序中使用的 R8 - R12 完全不同。它们是专用的中断处理资源,因此您不必像通常那样处理保存和恢复寄存器。

一些 PIC 单片机允许您对引脚 I/O 的相同地址进行写入和读取,但实际上,您写入的是一个单独的缓冲区而不是读取的缓冲区,因为写入引脚可能不一定会立即改变它们的状态。此配置允许架构在等待更改引脚状态时缓冲您的写入请求。这些额外的缓冲区有时也称为影子寄存器,看起来与您的示例相似。使用您的示例中给出的术语,我想这将被称为“预加载寄存器”。

通常,该术语用于指代您可以以相同方式处理的多个硬件资源。其中哪个是“真实”寄存器,哪个是“影子”寄存器在架构和供应商之间并不一致,最终也可能不是很重要。

于 2017-01-23T18:32:40.427 回答
3

实际上 ST 定义了它的标准:(General Timer Cookbook的第 14 页)

  • 活动寄存器实例(也称为影子寄存器实例):其内容被定时器外设逻辑用来生成定时器通道输出波形。
  • 预加载寄存器实例:这是当相关寄存器的预加载功能启用时软件访问的寄存器实例。

原始文件是 ST AN4776 应用笔记 - 可以在这里找到

于 2017-03-10T21:19:24.600 回答
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.

于 2021-05-12T07:18:30.917 回答