I'm trying to perform a multi-byte SPI transfer using the KSDK 1.2.0 "fsl_spi" component, as follows:
uint8_t sleepStringOut[] = {0x02 /* WRITE */, 0x0F /* ADDR = CANCTRL */, 0x20 /* REQOP = 0b001 */}; uint8_t sleepStringIn[] = {0x00, 0x00, 0x00}; spi_status_t result; result = SPI_DRV_MasterTransferBlocking(SPI0_IDX, NULL, sleepStringOut, NULL, 3, 10000); if(kStatus_SPI_Success != result) { for(;;) { /* Trap */ } }
Looking at the SPI bus on a logic analyzer, the driver de-asserts the slave select line between each byte of the transfer:
Is it possible to configure this driver to perform a multi-byte SPI transfer without de-asserting slave select between bytes?
Thanks,
Dave
已解决! 转到解答。
Have you dove any further work on this particular issue? I've just begun development with the 1.3 version of the SDK and this behavior is still occurring and my SPI device does not respond. After much frustration and troubleshooting I narrowed it down to the CS line de-asserting itself in between bytes of the same transfer. Wondering if you determined if there's a bug in the SDK and whether you had a solution?
In my K21 SPI component:
dspi_status_t DSPI_DRV_MasterInit(uint32_t instance,
dspi_master_state_t * dspiState,
const dspi_master_user_config_t * userConfig)
There is a member <isChipSelectContinuous> in the 3rd parameter userConfig.
Yijun,
Thank you for your reply. I am working with a KL25 part that has a standard SPI component, not a DSPI. The definition for spi_master_user_config_t looks like:
/*!
* @brief Information about a device on the SPI bus.
* @internal gui name="Master configuration" id="spiMasterCfg"
*/
typedef struct SPIUserConfig {
uint32_t bitsPerSec; /*!< SPI baud rate in bits per sec @internal gui name="Clock rate" id="MasterBaudRate" */
spi_clock_polarity_t polarity; /*!< Active high or low clock polarity @internal gui name="Polarity" id="MasterPolarity" */
spi_clock_phase_t phase; /*!< Clock phase setting to change and capture data @internal gui name="Phase" id="MasterPhase" */
spi_shift_direction_t direction; /*!< MSB or LSB data shift direction @internal gui name="Direction" id="MasterDirection" */
/* 16-bit support related members */
#if FSL_FEATURE_SPI_16BIT_TRANSFERS
spi_data_bitcount_mode_t bitCount; /*!< Number of bits (8 or 16) in a transfer @internal gui name="Bit count" id="MasterBitCount" */
#endif
} spi_master_user_config_t;
There is no "isChipSelectContinuous" parameter.
Thanks,
Dave
Dave ,
Another clue:
SPI_HAL_SetSlaveSelectOutputMode(base, kSpiSlaveSelect_AutomaticOutput);
or you can check KL25 Reference Manual for SPI settings.
Maybe KL25 and MK21 has different SPI architecture.