AnsweredAssumed Answered

FlexSPI - SCK

Question asked by variable_andrew on Aug 15, 2019
Latest reply on Aug 28, 2019 by Kerry Zhou

I've altered the flexspi_nor_polling_transfer demo (for RT1015  MCUXpresso) to fit my board's SPI Flash (the TC58CVG2S0HRAIG NAND FLASH).

 

Could you clarify the usage of the LUT command + FlexSPI command?

  1. should I replace 0xC0 with the # of bits expected for the transfer?
  2. is the 0x01 on the READ_SDR supplosed to be 0x08 for bits? or are read arguments in bytes, while addresses are in bits?
 /* Read Status */
 [4 * NAND_CMD_LUT_SEQ_IDX_READSTATUS] = FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x0F, kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xC0),
[4 * NAND_CMD_LUT_SEQ_IDX_READSTATUS + 1] = FLEXSPI_LUT_SEQ(kFLEXSPI_Command_READ_SDR, kFLEXSPI_1PAD, 0x01, kFLEXSPI_Command_STOP, kFLEXSPI_1PAD, 0),

Should the calling function that uses that to wait while busy look like this: (isn't the 0xC0 here redundant?)

status_t flexspi_nand_wait_bus_busy(FLEXSPI_Type *base){
    /* Wait status ready. */
    bool isBusy;
    uint32_t readValue;
    status_t status;
    flexspi_transfer_t flashXfer;

    flashXfer.deviceAddress = 0xC0;
    flashXfer.port          = kFLEXSPI_PortA1;
    flashXfer.cmdType       = kFLEXSPI_Read;
    flashXfer.SeqNumber     = 1;
    flashXfer.seqIndex      = NAND_CMD_LUT_SEQ_IDX_READSTATUS;
    flashXfer.data          = &readValue;
    flashXfer.dataSize      = 1;

    do {
        status = FLEXSPI_TransferBlocking(base, &flashXfer);
        if (status != kStatus_Success) {
            return status;
        }
        isBusy = (readValue & 0x01) == 0x01;
    } while (isBusy);
    return status;
}

 

When I run - the data on the SPI lines aren't right (CS asserts in the middle of a byte, SCK isn't consistent, sometimes doesn't toggle for a full transfer, etc).

 

(Below images show examples of weird behavior on the FlexSPI_D0, CS, and SCK  pins in order) 

cs weird assert  sck missing cycles

 

1. What might cause the above erratic behavior on the 

2. Where should the SCK frequency/baud rate be set?  I assumed it's by updating flexspiRootClk as per:

 

flexspi_device_config_t deviceconfig = {

    .flexspiRootClk       = 104000000, //133000000,

    .flashSize            = FLASH_SIZE,

    .CSIntervalUnit       = kFLEXSPI_CsIntervalUnit1SckCycle,

    .CSInterval           = 2,

    .CSHoldTime           = 3,

    .CSSetupTime          = 3,

    .dataValidTime        = 0,

    .columnspace          = 0,

    .enableWordAddress    = 0,

    .AWRSeqIndex          = 0,

    .AWRSeqNumber         = 0,

    .ARDSeqIndex          = NAND_CMD_LUT_SEQ_IDX_READ_FROM_CACHE,

    .ARDSeqNumber         = 1,

    .AHBWriteWaitUnit     = kFLEXSPI_AhbWriteWaitUnit2AhbCycle,

    .AHBWriteWaitInterval = 0,

};

Outcomes