Data stall - SPI Master Transmiter - LPC55S04

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Data stall - SPI Master Transmiter - LPC55S04

Jump to solution
1,297 Views
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 Kudos
1 Solution
1,286 Views
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.

View solution in original post

0 Kudos
1 Reply
1,287 Views
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 Kudos