STM32 SAI:了解FIFO
STM32 SAI: Understanding FIFO
据我了解,FIFO(在硬件上下文中)是一个缓冲区,将根据先进先出的原则进行管理。您按顺序将一些位放入其中,然后您可以读取它们,即在达到所需阈值时逐块读取。但是我对STM32串行音频接口的FIFO管理很困惑:
根据数据表,串行音频接口 (SAI) 支持最多 8 个字的 FIFO。 (8x32bits) SAI的数据寄存器(SAI_xDR)为1个字(32bits)。文档说明
A write to this register loads the FIFO provided the FIFO is not full.
A read from this register empties the FIFO if the FIFO is not empty.
如何解读?
我的猜测是:如果我对该寄存器进行写访问,它会将寄存器内容(32 位块)作为第一个字加载到 FIFO 中,然后在第二次写访问时,它将第二个字加载到先进先出等。然后当我进行读取访问时,它 returns 是队列中的第一个单词,然后是第二个,依此类推。这样对吗?
如果是这样,当我向寄存器写入少于 32 位时会发生什么情况? IE。我写了一个 16 位块。然后我又写了一个16bits。两个位块是否共享一个字或它们被转移到单独的字?如果我读一个字,我会得到两个 16 位块还是只得到第一个 16 位?我不明白 FIFO 如何知道我填充到数据寄存器中的位序列的大小。还是在每次写访问时总是占用整个 32 位?
My guess is: If I make a writing access to this register, … Is this right?
是的,你是对的。
据我了解,每个 FIFO 字都包含数据 for/from 一个 SAI 槽,与数据大小无关。 FIFO 与 32 位移位寄存器连接,而移位计数取决于数据大小。
例如,似乎可以使用 16 位数据访问 SAI_xDR 的下半部分以获得 8 < data_size <= 16
,但无论如何,整个 32 位 FIFO 字将用于传输并且仅 data_size
每个字的位将被移位 in/out.
36.3.9 Serial audio interface (SAI) Internal FIFOs
...
Each FIFO is an 8-word FIFO. Each read or write operation from/to the FIFO targets one word FIFO location whatever the access size. Each FIFO word contains one audio slot. FIFO pointers are incremented by one word after each access to the SAI_xDR register.
Data should be right aligned when it is written in the SAI_xDR.
Data received will be right aligned in the SAI_xDR.
据我了解,FIFO(在硬件上下文中)是一个缓冲区,将根据先进先出的原则进行管理。您按顺序将一些位放入其中,然后您可以读取它们,即在达到所需阈值时逐块读取。但是我对STM32串行音频接口的FIFO管理很困惑:
根据数据表,串行音频接口 (SAI) 支持最多 8 个字的 FIFO。 (8x32bits) SAI的数据寄存器(SAI_xDR)为1个字(32bits)。文档说明
A write to this register loads the FIFO provided the FIFO is not full.
A read from this register empties the FIFO if the FIFO is not empty.
如何解读?
我的猜测是:如果我对该寄存器进行写访问,它会将寄存器内容(32 位块)作为第一个字加载到 FIFO 中,然后在第二次写访问时,它将第二个字加载到先进先出等。然后当我进行读取访问时,它 returns 是队列中的第一个单词,然后是第二个,依此类推。这样对吗?
如果是这样,当我向寄存器写入少于 32 位时会发生什么情况? IE。我写了一个 16 位块。然后我又写了一个16bits。两个位块是否共享一个字或它们被转移到单独的字?如果我读一个字,我会得到两个 16 位块还是只得到第一个 16 位?我不明白 FIFO 如何知道我填充到数据寄存器中的位序列的大小。还是在每次写访问时总是占用整个 32 位?
My guess is: If I make a writing access to this register, … Is this right?
是的,你是对的。
据我了解,每个 FIFO 字都包含数据 for/from 一个 SAI 槽,与数据大小无关。 FIFO 与 32 位移位寄存器连接,而移位计数取决于数据大小。
例如,似乎可以使用 16 位数据访问 SAI_xDR 的下半部分以获得 8 < data_size <= 16
,但无论如何,整个 32 位 FIFO 字将用于传输并且仅 data_size
每个字的位将被移位 in/out.
36.3.9 Serial audio interface (SAI) Internal FIFOs
...
Each FIFO is an 8-word FIFO. Each read or write operation from/to the FIFO targets one word FIFO location whatever the access size. Each FIFO word contains one audio slot. FIFO pointers are incremented by one word after each access to the SAI_xDR register.
Data should be right aligned when it is written in the SAI_xDR.
Data received will be right aligned in the SAI_xDR.