I want to configure spi for communicating with an external NAND Flash module from MPC5748G mcu. Suppose I am transmitting 0x9F opcode from MCU to Flash via spi, then flash module will respond after 8 dummy clocks as per the design. Please see the screenshot for better understanding. Now after transmitting the data, in the receive buffer, the content is showing null. MCU is unable to get any data. Status is showing success. What could be the error over here??
If anyone have any SPI sample code for mpc5748g, please share it.
If this is communication protocol on connected slave device, then you CPU side (master), you will need to transmit 5 bytes: 0x9F plus 4 times dummy bytes. Are you doing it like that?
Another point what is needed to check is HW connection of connected device, typically some external pull resistors are needed for correct functionality.
Yes I am transmitting four more bytes after transmitting 0x9f.
Let me know if its the correct way to transmit.
Also, what is the value of dummy bytes? I am transmitting 0xA5 as dummy data. Is there any specific value to be transmitted?
I don't know what's the driver but in principle you can send any value for dummy bytes. Command need to keep CS asserted between data words - this can be achieved by setting CONT bit for all these words, excluding last one.
Continuous SS was already checked in the component inspector window of spi. Still it was not working. Other than calling spi_init() function, do I need to perform any other task prior to the transmission of data via spi, in case of w25n01xx NAND Flash module. For example do I need to perform any reset or disabling write protection etc..
I have checked example code dspi_master_mpc5748g and mentioned setting does affect CONT bit.
Have you measured with scope to check whether transmitted waveforms fit to communication protocol described in the datasheet of connected device? It is currently what I recommend to do to analyze root cause of the issue.
In the datasheet of winbond w25n01xx NAND Flash, below shown is mentioned for spi configuration. I think i have configured spi by taking that into account. Please correct me, if I am wrong.
Standard SPI instructions use the DI input pin to serially write instructions, addresses or data to the device on the rising edge of CLK. The DO output pin is used to read data or status from the device on the falling edge of CLK.
SPI bus operation Mode 0 (0,0) and 3 (1,1) are supported. The primary difference between Mode 0 and
Mode 3 concerns the normal state of the CLK signal when the SPI bus master is in standby and data is not being transferred to the Serial Flash. For Mode 0, the CLK signal is normally low on the falling and rising edges of /CS. For Mode 3, the CLK signal is normally high on the falling and rising edges of /CS.
const spi_master_t spi1_MasterConfig0 =
.baudRate = 100000,
.ssPolarity = SPI_ACTIVE_LOW,
.continuousSS = true,
.frameSize = 8,
.clockPhase = READ_ON_EVEN_EDGE,
.clockPolarity = SPI_ACTIVE_LOW,
.bitOrder = SPI_TRANSFER_MSB_FIRST,
.transferType = SPI_USING_INTERRUPTS,
.rxDMAChannel = 255U,
.txDMAChannel = 255U,
.callback = NULL,
.callbackParam = NULL,
.ssPin = 0,
.extension = NULL
I am sorry, I am afraid I don't understand your comment. The note says that your spi slave device support both clocking modes - continuous and non-continuous - but it is not related to CONT bit as discussed above.
For NAND FLASH, in MOSI, CS and clk lines the fall time and rise time needs to be <5ns. But currently when measured, the rise time is 12ns and fall time is 22ns. The master is MPC5748G and the slave is NAND Flash w25n01gv. So, from the MCU software side, is there any way to reduce the fall & rise time time for these output lines of spi.
Thank you so much.. That was really helpful. Now I am getting response. In oscilloscope, when MISO line is captured, the data is there and its the correct response also. But that data is not updated in received buffer in the spi function.
SPI_MasterTransferBlocking(&spi1Instance, &tx_buffer, &rx_buffer, 1, 100);
while(STATUS_SUCCESS != SPI_GetStatus(&spi1Instance));
always this receiver buffer is always empty.
Please help me to resolve it.
It seems like in POPR register, no data is loaded, But data is there in MISO line when checked using oscilloscope. What could be the reason for this?
I guess MSCR and IMCR is configured in the right way. MSCR[SSS] is 00000010, so input mux is assigned value 2 and input_mux_reg is assigned 300. input mux_1 to 7 are disabled. Also for the SPI input pin of MCU, HYSTERESYS, pull select and open drain are disabled. Do i need to modify any of these to receive data properly. If i am wrong, please do correct me.
SIUL_GPIO_PIN PI, pinPortIdx 142u, IMCR 300, MSCR[SSS]=00000010 (0X02)
If I understand you description right (what I am not sure) I think you have it configured incorrectly. You have to have configured 2 registers MSCR142 (to enable input buffer) and IMCR300 (i.e. MSCR812 in order to route pin to module input.