Closed Jake-Carter closed 3 weeks ago
@kenan-balci please test this fix against your findings from MSDK-1264
@Jake-Carter My tests failed under some conditions.
Thanks for the detailed tests @kenan-balci. Failing at 32 bytes is suspicious in that it's exactly the depth of the SPI FIFO.
I notice in the test code that the master (RX) transaction is started after the slave (TX). I wonder if the overhead for setting up the master DMA transaction simply longer than the TX transmission time. If that were the case, then data beyond the depth of the FIFO would be missed because the FIFO is completely full.
Can you try launching the RX side before the TX? ex:
// ...
// Slave sends - Master receives
master_req.txLen = 0;
master_req.rxLen = DATA_LEN;
slave_req.txLen = DATA_LEN;
slave_req.rxLen = 0;
/***** Perform Transaction *****/
MXC_GPIO_OutClr(gpio_p0_7.port, gpio_p0_7.mask);
#if MASTERDMA
MXC_DMA_ReleaseChannel(0);
MXC_DMA_ReleaseChannel(1);
NVIC_EnableIRQ(DMA0_IRQn);
NVIC_EnableIRQ(DMA1_IRQn);
MXC_SPI_MasterTransactionDMA(&master_req, MXC_DMA0); // Launch RX to prepare for TX data
#endif
MXC_SPI_SlaveTransactionAsync(&slave_req); // Launch TX
#if MASTERSYNC
MXC_SPI_MasterTransaction(&master_req);
#endif
#if MASTERDMA
while (DMA_FLAG == 0) {}
DMA_FLAG = 0;
#endif
// ...
@Jake-Carter Changing the test code did not work.
Sending more than 32 bytes succeeds in the MASTERSYNC configuration, but it fails with MASTERDMA.
Strange... it seems like data past 32 bytes is at least being read in, but now it's corrupted...
Are you able to capture a logic analyzer trace of the pins? I think the slave should not start transmitting data until the master drives both SS and SCK low. The slave's data transmission should be completely clocked out by SCK. Considering this I guess it would make sense that the second test is corrupted, but I'm not sure why it would stop after the FIFO depth for the first test...
It would be helpful to see what's happening on the bus to continue troubleshooting
@Jake-Carter Logic analyzer output for 3 wire SPI receive op. with DMA:
Logic analyzer output for a 3-wire SPI receive op. without DMA:
It seems that the slave sends incorrect data after 32 bytes. Master is reading the values it receives correctly. It's a strange bug, I'll try to debug it when I have time.
This pull request is stale because it has been open for 30 days with no activity. Remove stale label, commit, or comment or this will be closed in 7 days.
This pull request is stale because it has been open for 30 days with no activity. Remove stale label, commit, or comment or this will be closed in 7 days.
This pull request was closed because it has been stalled for 7 days with no activity.
Description
This PR updates the SPI Rev A1 DMA drivers to work with read-only and/or asymmetrical transactions (txLen == 0 or txLen < rxLen).
Reported by internal Jira MSDK-1264
The problematic logic seems to be the
txrx_req
logic.If txLen is 0, then
.txrx_req
is set to 0 and the logical condition for releasing both DMA channels is satisfied even if the RX channel's CTZ has not fired..mtMode
also never seems to be set to 1 at all in the drivers.Previous implementation...
Checklist Before Requesting Review