Hello,
I am having trouble reading from the RT1170 evaluation board in SPI 4-wire mode. I read the AN5320 and also the i.MX RT1170 Processor Reference Manual but I cannot solve two main problems:
1. Before reading the data (as I work in master mode) the processor has to send 4 command bytes. So first I send 4 bytes in transmit mode (this works just fine). After these 4 bytes are sent I change the Pin configuration register (base->CFGR1 |= LPSPI_CFGR1_PINCFG(kLPSPI_SdiInSdiOut);) to swap SDI and SDO pins (I do not know why but this is necessary if I want DATA0 & DATA1 bits to read properly). The problem is that it changes the pin configuration BEFORE finishing the send operation, therefore in the last byte DATA0 and DATA1 pins are swapped. Before changing CFGR1 register I wait for the TX fifo to be empty.
2. When reading (once the first 4 bytes are transmitted) I start reading. To do so I clear the RXMSK value in the TCR register (no save the data in the FIFO) and then I set the TXMSK to start a transmission (trigger the clocks so the slave starts responding). The problem in this case is that I do not know how to stop the trasmission process when I want to. As I want to read 4 bytes I wait for the RXFifoCount to be 4 and then I stop the transmission by clearing the continuous mask and clearing the TXMSK value in the TCR register. It always read at least 5 bytes and the stop process does not work properly either.
I know I am doing something wrong but I cannot figure out what. As I mentioned before, I followed the instructions on the AN5320 appnote and I also read the reference manual to check for possible registers to read or write but I did not have any success.
I attach the main file. The project is based on the polling_b2b_transfer_master but it has been severely changed to be used as 4 wire mode. The main problem (the reading function) is called "LPSPI_MasterReceiveBlocking".
Any suggestion will be appreciated,
Lander