A common root cause of incorrect readings after a subcommand is not waiting enough time for the device to complete the operation. Most subcommands take a typical time of 500us to execute. Some alternatives to make sure the device has completed the operation and data is available are:
- Polling: Host controller can poll the
subcommand address (0x3E and 0x3F) to make sure the previously writen subcommand
value is readback. This maintains that was propertly executed and the data is
now available on read transfer buffer (0x40). Section 3.1 Direct Commands and
Subcommands of the TRM provides a detail pseudocode for polling
subcommands.
- Wait: Given enough time for the command or
command-only subcommand to execute is the best recommendation, this maintains
that execution is completed and saves processor power by setting the host on
idle state instead of polling the registers. A recommended value of 2ms is
suggested to maintain that enough margin is given for all command
operations.
For reference, Table 9-2 Command/Subcommand Operation Time of the Technical Reference Manual describes the typical execution times to
complete command and subcommand operations.