According to the standard 3-line SPI reading method, I tried to read the version value 0x006 of LMK04821, but after I sent 0x8006, the last 8 CLKS did not receive the data I needed from SDI. I have verified that the register can be written successfully (after the clock is turned on, Sends 0x01 found clock is off to 0x002). I tried not initializing the clock after system startup and then carrying out the read operation, but it did not work. Is the read operation related to the register configuration at the beginning? The following is my user layer to read the register code.
To simplify my problem: How do I read the register value, ignoring the impact of possible previous register configuration operations on it?
/* set spi mode, bits and speed */ SPI_set_mode(MODE_0); SPI_set_bits(8_BITS); SPI_set_speed(1000000); /* data to be send */ unsigned char tx_buf[] = {0x80, 0x06, 0x00}; unsigned char rx_buf[3] = {0, }; struct spi_ioc_transfer tr = { .tx_buf = (unsigned long)tx_buf, .rx_buf = (unsigned long)rx_buf, .len = 3, .delay_usecs = 0 }; ioctl(fd, SPI_IOC_MESSAGE(1), &tr);