Apb Interview Question
Apb Interview Question
For APB usage, Does APB allow connection with different data
width? means Narrow/Wide APB master point connects to
Wide/Narrow APB peripherals.
You can connect APB device with differing data bus widths to a common APB
master, but as the APB protocol does not have any "size" signal, accesses
from the APB master will be accessing the full width of the APB data bus.
So if you had a 32-bit data bus, and a 16-bit APB device, if the registers in
that device were aligned to 2-byte addresses (to match that the peripheral
contains 16-bit registers), an APB access from the master would then read
or write to 2 adjacent registers in that peripheral
Using the latest APB protocol, APB4, this does have a PSTRB signal
that declares which bytes on the data bus are being written to, so that
would ensure only the relevant "narrow" register is being accessed, but
these aren't used for read accesses, so you could accidentally corrupt
read sensitive registers if 2 registers are accessed by one APB
master transfer.
What you can do is align the peripheral registers to addresses that are target
system data bus width aligned, so in my example making the 16-bit
peripheral registers all aligned to 4-byte boundaries. Then one APB transfer
will just access one register in the target device.
But that means the peripheral has to be designed for a specific APB data bus
width, although most APB master designs I have seen are 32-bit designs, so
standardising on that width alignment for registers could be the way to
ensure your peripheral would work in typical applications if you want to mix
different individual peripheral data bus widths.