Hi-
I just upgraded my SPI driver to MQX4.1.1 from legacy SPI driver from MQX3.8.
When I debugging through the failure when calling function fread() in my application, I noticed that function _dspi_tx_rx() inside spi_dspi.c:
data = dspi_info_ptr->DUMMY_PATTERN;
...
else
{
rx_len = tx_len = len;
/* Optimized loop for single byte frames */
while (rx_len)
{
if (tx_len) {
if ((dspi_ptr->SR & DSPI_SR_TFFF_MASK) && ((rx_len-tx_len)<DSPI_FIFO_DEPTH))
{
if (txbuf)
data = *txbuf++;
dspi_ptr->PUSHR = DSPI_PUSHR_TXDATA(data);
dspi_ptr->SR = DSPI_SR_TFFF_MASK;
tx_len--;
...
The data above is supposed to hold the dummy pattern to be sent out when fread() is called. However, it is never used in this function. Can someone tell me why and how to make dummy pattern work? Actually fread() will call _io_spi_read_write(fd_ptr, NULL, data_ptr, n); in which Tx buffer is set to NULL and in this function:
if ((wrbuf == NULL) && (dev_data->FLAGS & SPI_FLAG_FULL_DUPLEX)) | |
{ | |
wrbuf = rdbuf; | |
} |
wrbuf is made share same buffer with rdbuf. Seems like half-duplex in MQX3.8 is not supported anymore (by _dspi_polled_rx())?.
In addition, no matter what value I set to DSPI_FIFO_DEPTH, I can't get ISR to run. The code in _dspi_tx_rx() simply works in polling mode. How can I enable interrupt mode?
Thanks!
Hui
Hello,
Please check the below thread and let me know if this helps!!!
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Sol
Thanks for the link above. The interrupt I am looking at are the ones within SPI driver and they should have been properly installed
static _mqx_int _dspi_init ( )
{
...
for (i=0; i<dspi_info_ptr->NUM_VECTORS; i++) | |
{ | |
_int_install_isr(vectors[i], _dspi_isr, dspi_info_ptr); | |
_bsp_int_init((PSP_INTERRUPT_TABLE_INDEX)vectors[i], BSP_DSPI_INT_LEVEL, 0, TRUE); | |
} |
...
}
Seems like the ISR is called only under condition where (rx_len-tx_len) greater or equal DSPI_FIFO_DEPTH?
Besides, how to make the DUMMY_PATTERN work? I can't find anywhere it is set to SPI hardware.
Thanks!
Hui