Data stall - SPI Master Transmiter - LPC55S04

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Data stall - SPI Master Transmiter - LPC55S04

跳至解决方案
1,521 次查看
mdoyon
Contributor I

I have been struggling the past couple of days to send multiple bytes using the SPI_MasterHalfDuplexTransferNonBlocking() function from the SD_2.x_LPC55S04 . I didn't find a way so far to toggle back SCLK between each frame (see picture attached). According to the user manual and the debugging tool, the transmitter is on stall mode. The only way I found so far was to use the EOT bit and send by packages with only 8 bits of data and #CS toggling each time. 

const spi_master_config_t FLEXCOMM3_config = {
.enableLoopback = false,
.enableMaster = true,
.polarity = kSPI_ClockPolarityActiveHigh,
.phase = kSPI_ClockPhaseFirstEdge,
.direction = kSPI_MsbFirst,
.baudRate_Bps = 4000000UL,
.dataWidth = kSPI_Data8Bits,
.sselNum = kSPI_Ssel0,
.sselPol = kSPI_SpolActiveAllLow,
.txWatermark = kSPI_TxFifo0,
.rxWatermark = kSPI_RxFifo1,
.delayConfig = {
.preDelay = 0U,
.postDelay = 0U,
.frameDelay = 0x1U,
.transferDelay = 0x1U
}
};

 

static void FLEXCOMM3_init(void) {
/* Initialization function */
SPI_MasterInit(FLEXCOMM3_PERIPHERAL, &FLEXCOMM3_config, FLEXCOMM3_CLOCK_SOURCE);
}

 

void taskSpi(void *pvParameters){

while(1)
{
SPI_MasterHalfDuplexTransferNonBlocking(SPI3, &spiHandle, &xfer);
while(!isFinished) {

}

isFinished = false;

// Send out.

vTaskDelay(2000/portTICK_PERIOD_MS);

}

 

// Prepare to send.
sendData[0] = WRITE_CONFIGURATION_3;
sendData[1] = KEEP_ALIVE_160_MICRO_SEC;

xfer.txData = sendData;
xfer.rxData = receiveBuff;

xfer.txDataSize = 2;
xfer.configFlags = kSPI_FrameAssert;
xfer.isTransmitFirst = true;


xfer.configFlags = kSPI_FrameDelay;xTaskCreate(taskSpi, "task2", 128, NULL, 2, NULL);
vTaskStartScheduler();

Any tips would be appreciated. 

0 项奖励
回复
1 解答
1,510 次查看
mdoyon
Contributor I

Finally got it to work. The issue was in the clock settings. Main clock was too slow compared to FLEXCOMM3 which didn't give enough time to fill the FIFO.

在原帖中查看解决方案

0 项奖励
回复
1 回复
1,511 次查看
mdoyon
Contributor I

Finally got it to work. The issue was in the clock settings. Main clock was too slow compared to FLEXCOMM3 which didn't give enough time to fill the FIFO.

0 项奖励
回复