I'm working on a project using a FRDM-KL82Z board, with the MKL82Z128 microcontroller. I use the SEGGER J-Link EDU programmer and MCUXpresso 10.0.2 IDE.
I want to write data from the MCU to the external flash, which is the MX25L12845G.
I have no experience working with neither QSPI nor flash, so I've taken the frdmkl82z_driver_examples_qspi_polling_transfer example from the SDK and the datasheet as a reference. I think I more or less understand how to make it work, although I have some questions.
I've been able to write data with size between 16 and 64 bytes (limits included) and more or equal to 80 bytes. I know how to manage the jump to the next page and so on. In the flash datasheet (MX25L12845G, Page 6) it says that it can be written in byte, word or page mode.
From my understanding, the way to write to Flash is writing data into the TxFIFO (which has 16 positions of 4 bytes each = 64 bytes). The example uses the QSPI_WriteBlocking function, which asks for 16 or more bytes of data with the initial assert. If I want to write more than 64 bytes, once the TxFIFO is full the QSPI_WriteBlocking function waits until there's a free position in the FIFO and adds the next one.
I have tried to modify the assert in the QSPI_WriteBlockingi function to see what happens if I try to write less than 16 bytes (12, 8 or 4 bytes) and the program writes the number or elements I tell him but it writes all 0s. If I follow the fsl functions I see that the QuadSPI TBDR (TX Buffer Data Register) gets the values I tell him, so it seems as something in a lower level. The IP commands doesn't seem to have any parameter that could solve this, except the QSPI_SetIPCommandSize, which I give the number of bytes to write and seems to work for the range of values that I mentioned before.
Also, I don't know when the QSPI_SoftwareReset function is needed to be used. The SDK example uses it every page write, but there's no info about why it is needed.
Does anyone know how to do it? I'd be very grateful as I've been some days trying to figure it out but I haven't succeeded.
Thank you so much,