AN202
V1.0 | Page 14/73
www.cmostek.com
Note:
1. After completing the SOFT_RST at the Step2, it needs to wait for 1ms before the Step3 operation.
2. Step6 is a configuration register operation, which is not a direct write operation, but an indirect operation
through internal circuit. So writing a register must repeat the process of Step6:
3. Write the target register address to 0x18.
4. The low 8-bit of the 16-bit data is written to 0x19.
5. The high 8-bit of the 16-bitdata is written to 0x1A.
6. Write 0x01 to the register 0x25, triggering the operation will take effect.
For example: The value to be written is 0xC3F6. The target address is 0x02. According to Step6, the process
is as follows:
TWI_WRREG(0x18, 0x02);
// Write the Addr 0x02 to register 0x18
TWI_WRREG(0x19, 0xF6);
// Write the Low_data 0xF6 to register 0x19
TWI_WRREG(0x1A, 0xC3); // Write the High_data 0xC3 to register 0x1A
TWI_WRREG(0x25, 0x01);
//Trigger the overwriting to the feature register, the writing process
completes
In the configuration above, you can repeat the Step6 process in the Step6 stage, and configure all the
registers that need to be. When the user needs to do a read operation to confirm whether the write operation
is correct, the read operation is also indirect, similar to the Step6 process.
For example: The read address is 0x02, the process is as follows:
TWI_WRREG(0x18, 0x02); // Write the Addr 0x02 to register 0x18
TWI_RDREG(0x1B, DATAL);
// Read theLow_data from 0x1B and store it in the DATAL variable
TWI_RDREG(0x1C, DATAH);
// Read the High_data from 0x1C and store it in the DATAH variable
But users need to notice that the read operation is the same as the write operation. The front Step1 to Step5
still needs to be executed, and reading and writing can be done in the Step6 stage.
2.7
Complete Transmission Process
A complete transmission process includes the parameter configuration, transmission, resetting TWI bus and
RF part, as shown in the following figure:
One Transmission Cycle
(1 ) - TWI_RST
(2 ) - SOFT_RST
(1 ) - TWI_RST
(2 ) - SOFT_RST
TRANSMISSION
Reset TWI
One Transmission Cycle
(1 ) - TWI_RST
(2 ) - SOFT_RST
TRANSMISSION
(1 ) - TWI_RST
(3 ) - TWI_OFF
(2 ) - Step2 to Step6
(1 ) - TWI_RST
(3 ) - TWI_OFF
(2 ) - Step2 to Step6
Figure 2-10. Configure Parameters for Each Transmission
The advantage of configuring parameters for each transmission is reliable. At the same time, after completing