SPRAA85E November 2005 – December 2017 SM320F2812 , SM320F2812-EP , TMS320F280021 , TMS320F280021-Q1 , TMS320F280023 , TMS320F280023-Q1 , TMS320F280023C , TMS320F280025 , TMS320F280025-Q1 , TMS320F280025C , TMS320F280025C-Q1 , TMS320F280040-Q1 , TMS320F280040C-Q1 , TMS320F280041 , TMS320F280041-Q1 , TMS320F280041C , TMS320F280041C-Q1 , TMS320F280045 , TMS320F280048-Q1 , TMS320F280048C-Q1 , TMS320F280049 , TMS320F280049-Q1 , TMS320F280049C , TMS320F280049C-Q1 , TMS320F2801 , TMS320F2801-Q1 , TMS320F2802 , TMS320F2802-Q1 , TMS320F28044 , TMS320F2806 , TMS320F2806-Q1 , TMS320F28062 , TMS320F28062-Q1 , TMS320F28062F , TMS320F28062F-Q1 , TMS320F28063 , TMS320F28064 , TMS320F28065 , TMS320F28066 , TMS320F28066-Q1 , TMS320F28067 , TMS320F28067-Q1 , TMS320F28068F , TMS320F28068M , TMS320F28069 , TMS320F28069-Q1 , TMS320F28069F , TMS320F28069F-Q1 , TMS320F28069M , TMS320F28069M-Q1 , TMS320F28075 , TMS320F28075-Q1 , TMS320F2808 , TMS320F2808-Q1 , TMS320F2809 , TMS320F2810 , TMS320F2810-Q1 , TMS320F2811 , TMS320F2811-Q1 , TMS320F2812 , TMS320F2812-Q1 , TMS320F28232 , TMS320F28232-Q1 , TMS320F28234 , TMS320F28234-Q1 , TMS320F28235 , TMS320F28235-Q1 , TMS320F28332 , TMS320F28333 , TMS320F28334 , TMS320F28335 , TMS320F28335-Q1 , TMS320F28374D , TMS320F28374S , TMS320F28375D , TMS320F28375S , TMS320F28375S-Q1 , TMS320F28376D , TMS320F28376S , TMS320F28377D , TMS320F28377D-EP , TMS320F28377D-Q1 , TMS320F28377S , TMS320F28377S-Q1 , TMS320F28379D , TMS320F28379D-Q1 , TMS320F28379S , TMS320R2811
AND @Var, #0xFFFC ; Read 16-bit value "Var"
; AND the value with 0xFFFC
; Write the 16-bit result to "Var"
;
;
OR @Var, #0x0010 ; Read 16-bit value "Var"
; OR the value with 0x0010
; Write the 16-bit result to "Var"
;
;
XOR @VarB, AL ; Read 16-bit value "Var"
; XOR with AL
; Write the 16-bit result to "Var"
;
;
MOVB *+XAR2[0], AH.LSB ; Read 16-bit value pointed to by XAR2
; Modify the least significant byte
; Write the 16-bit value back
With a full CPU pipeline, a C28x based device can complete one read-modify-write operation to zero wait-state SARAM every cycle. When accessing the peripheral registers or external memory, however, required wait states must be taken into account. In addition, the pipeline protection mechanism can further stall instructions in the CPU pipeline. This is described in more detail in Section 5 and in the TMS320C28x CPU and Instruction Set Reference Guide (SPRU430).
Read-modify-write instructions usually have no ill side effects. It is important, however, to realize that read-modify-write instructions do not limit access to only specific bits in the register; these instructions write to all of the register's bits. In some cases, the read-modify-write sequence can cause unexpected results when bits are written to with the value originally read. Registers that are sensitive to read-modify-write instructions fall into three categories:
Registers that fall into these three categories are typically found within older peripherals. To keep register compatibility, the register files have not been redesigned to avoid this issue. Newer peripherals, such as the ePWM, eCAP, and eQEP, however, have a register layout specifically designed to avoid these problems.
This section describes in detail the three categories in which read-modify-write operations should be used with care. In addition, an example of each type of register is given along with a suggested method for safely modifying that register. At the end of the section a list of read-modify-write sensitive registers is provided for reference.