Hi @haolin
To send commands and data via the MTDR register, the typical format is:
LPI2Cn->MTDR = (CMD << 8) | DATA;
Based on the information you provided, you intend to transmit a START condition with an address. In this case, CMD = 0x4 and DATA = 0x20. However, it is important to note that DATA is a 7-bit address with a Read/Write (R/W) bit as the least significant bit (LSB). The format should be:
LPI2Cn->MTDR = (CMD << 8) | ((address << 1) | 0); // For write operation
LPI2Cn->MTDR = (CMD << 8) | ((address << 1) | 1); // For read operation
Please ensure that the address is correctly shifted and the R/W bit is properly set depending on the intended operation.
BR, VaneB