25.6.6 Command and Data Interface
The NVM Controller is addressable from the APB bus, while the NVM main address space is addressable from the AHB bus. Read and automatic page write operations are performed by addressing the NVM main address space directly, while other operations such as manual page writes and block erase must be performed by issuing commands through the NVM Controller.
To issue a command, the CTRLB.CMD bits must be written along with the CTRLB.CMDEX value (0xA5). STATUS.READY is cleared when a command is issued and set when it has completed. Any command written while STATUS.READY is low will be ignored causing INTFLAG.PROGE to rise. Refer to the CTRLB register description for more details.
Invalid commands are discarded and will set INTFLAG.PROGE and INTFLAG.DONE when issued.
The CTRLA register must be used to control the power reduction mode, read wait states, and the write mode.
Commands that require an address use the ADDR register as an argument. ADDR APB write access is locked by the NVMCTRL while being used internally. For instance if a write operation is started by the NVMCTRL, an APB write is discarded so that the write operation is performed at the correct address. The discarded APB write is signaled by rising INTFLAG.ADDRE. Commands that needs an address will fail if issued while INTFLAG.ADDRE is set, such failure is signaled by rising INTFLAG.PROGE.
The APB ADDR register is updated upon:
- APB writes to the ADDR register address
- AHB writes to the page buffer
ADDR APB writes are discarded and report an INTFLAG.ADDRE error in the following cases:
- When written from APB while a command is reading it
- ADDR APB write access while writing the page buffer (AHB write): ADDR is written upon AHB writes and must stay valid until the page buffer has been written and also until automatic write command has been issued to the command interface when in automatic write mode (WMODE configured as ADW or AQW or AP)
- ADDR APB write access while the command interface reads it
- A command is executed at an illegal address
All commands that require an address are discarded when INTFLAG.ADDRE is set. INTFLAG.PROGE is set in this case. INTFLAG.ADDRE must be cleared before issuing such commands.