The complete mechanics of an APB write transfer — Setup phase, Access phase, how PREADY inserts wait states, which signals must remain stable and for how long, and back-to-back write transfers to the same peripheral.
Every APB transfer — read or write — follows the same two-phase structure. Understanding this structure is the foundation for everything else in the APB protocol.
The Setup phase always lasts exactly one clock cycle. There are no wait states during Setup — PENABLE is always asserted on the very next rising edge after PSELx. The Requester uses the Setup cycle to present the address, write data, and control signals to the Completer so the peripheral has one full cycle to decode the address and prepare for the transfer.
The Access phase lasts at least one cycle. If the Completer deasserts PREADY, additional cycles are inserted. There is no maximum on the number of wait state cycles — a peripheral could theoretically hold PREADY LOW indefinitely (though this would deadlock the system bus and is never done in practice).
At the end of the Access phase (when PREADY goes HIGH), PENABLE is deasserted. If another transfer to the same peripheral follows immediately, PSELx remains asserted and Setup begins again on the next cycle. If no further transfer is required, PSELx is also deasserted and the interface returns to IDLE.
The simplest APB write: the Completer asserts PREADY in the first Access cycle, completing the transfer in exactly two clock cycles total.
Walking through each clock edge:
A Completer that needs more than one Access cycle drives PREADY LOW during the Access phase. Each cycle with PREADY=0 inserts one wait state. The number of wait states is unlimited — the Completer can hold PREADY LOW for as many cycles as it needs.
The key thing to understand about wait states: the entire APB bus is frozen while PREADY is LOW. Nothing changes — not the address, not the write data, not the direction, not the select or enable signals. The Completer is the only thing that can change state, and it does so internally while keeping PREADY LOW. When it is ready to accept the write, it drives PREADY HIGH and the transfer completes on the next rising edge.
The spec defines precisely which signals must remain stable during a write transfer. This is one of the most important rules for implementers — violating it causes undefined peripheral behaviour.
| Signal | Must be stable from | Until | Notes |
|---|---|---|---|
PADDR | Start of Setup phase | Transfer completes (PREADY=1) | Must not change during wait states |
PWRITE | Start of Setup phase | Transfer completes | Must be HIGH for entire write transfer |
PSELx | Start of Setup phase | Transfer completes | Must not be deasserted during wait states |
PENABLE | Start of Access phase | Transfer completes | Already asserted; must stay asserted through wait states |
PWDATA | Start of Setup phase | Transfer completes | Active write byte lanes must be valid and stable |
PSTRB | Start of Setup phase | Transfer completes | APB4+ only; must stay stable like PWDATA |
PPROT | Start of Setup phase | Transfer completes | APB4+ only; same stability requirement as PADDR |
PAUSER | Start of Setup phase | Transfer completes | APB5+ only; must be same in Setup and Access |
PWUSER | Start of Setup phase | Transfer completes | APB5+ only; write only; must be same in Setup and Access |
The spec states these signals must be stable across all wait state cycles — not just between Setup and Access. A peripheral’s register write logic typically latches PWDATA on the cycle where PSELx, PENABLE, and PREADY are all HIGH. If PWDATA changes during a wait state, the peripheral’s latch would capture the wrong data.
When the APB bridge needs to write to the same peripheral on consecutive cycles, it can keep PSELx asserted and immediately start a new Setup phase after the previous transfer completes. This saves the one idle cycle that would otherwise occur between separate transfers.
The critical point: PENABLE must be deasserted between every transfer, even in back-to-back mode. The Setup phase is mandatory for every transfer. The Completer uses the deasserted PENABLE as the signal that a new transfer is beginning — it distinguishes a new write from a wait state of the previous write.
The key difference between APB2 and APB3 write transfers is PREADY:
| Aspect | APB2 | APB3+ |
|---|---|---|
| PREADY signal | Not present — Completer does not have this signal | Present — Completer drives PREADY |
| Transfer duration | Always exactly 2 cycles (fixed) | 2+ cycles (variable, controlled by PREADY) |
| Wait states | Not possible — no mechanism to extend | Inserted by driving PREADY=0 during Access |
| Connection to APB3 bridge | Tie PREADY input HIGH at bridge. Default value = 1’b1. | Connect PREADY output from peripheral to bridge |
| Error reporting | Not possible — no PSLVERR signal | PSLVERR asserted with PREADY to signal error |
When you have an APB3 bridge and an APB2 peripheral, the solution is always the same: tie the PREADY input for that peripheral’s slot to 1’b1. This makes the bridge behave as if PREADY is always asserted — effectively a two-cycle fixed transfer for every access to that peripheral.
| Item | Rule |
|---|---|
| Minimum write transfer duration | 2 cycles — one Setup + one Access with PREADY=1 |
| Setup phase duration | Always exactly 1 cycle — no wait states during Setup |
| Access phase duration | 1 cycle minimum; extended by 1 per PREADY=0 cycle |
| PENABLE during Setup | Must be LOW (deasserted) |
| PENABLE during Access | Must be HIGH (asserted) and remain HIGH through all wait states |
| PREADY during Setup | Irrelevant — can be any value; ignored by Requester |
| Transfer completes when | PSELx=1 AND PENABLE=1 AND PREADY=1 on rising PCLK edge |
| Signals stable during wait states | PADDR, PWRITE, PSELx, PENABLE, PWDATA, PSTRB, PPROT, PAUSER, PWUSER |
| APB2 peripheral with APB3 bridge | Tie PREADY=1 for that peripheral — fixed 2-cycle transfers |
| Back-to-back same peripheral | PSELx stays HIGH; PENABLE deasserted for 1 cycle (new Setup), then asserted again |
| Back-to-back different peripheral | PSELx changes; typically one IDLE cycle between transfers |
| Data latched by Completer at | Rising PCLK edge when PSELx=1, PENABLE=1, PREADY=1, PWRITE=1 |