Forums - SPI delay

10 posts / 0 new
Last post
SPI delay
yury.gureev
Join Date: 18 Jun 18
Posts: 8
Posted: Tue, 2018-06-19 02:42

Hi.

I use API function qapi_SPIM_Full_Duplex() for SPI transfer and callback function for wait end of transfer.

In the whole it's working OK but if I looked timing via oscilloscope, I see stange things - time between call of function qapi_SPIM_Full_Duplex() and start of SPI transfer is at least 50 us. Time between end of SPI transfer and call of callback funtion is at least 40 us.

Therefore transfer of 5 bytes via SPI which duration must be no more 3 us (SPI clock speed = 16 MHz), in real have duration about 100 us.

Unfortunately fast SPI transfer its key parameter of my system. Could I something fix?

  • Up0
  • Down0
manjulak Moderator
Join Date: 5 Dec 14
Posts: 33
Posted: Wed, 2018-06-20 01:28

Are you trying these SPI transfers by disabling sleep? Can you please share demo code with which you are seeing this delay? Are there any console print messages in your code causing this delay? Can you please try by setting high speed mode (config.hsmode = 1) and set rx_info as NULL in qapi_SPIM_Full_Duplex()? What is the SPI clock speed you set in your code?

  • Up0
  • Down0
yury.gureev
Join Date: 18 Jun 18
Posts: 8
Posted: Wed, 2018-06-20 09:20

Demo code:

 
#define SPI_DONE    0x01
 
static qurt_signal_t         spi_signal;
static void                 *spi_handle;
static qapi_SPIM_Config_t    spi_conf;
static qapi_SPIM_Transfer_t  spi_tx_data;
static qapi_SPIM_Transfer_t  spi_rx_data;
 
static void spi_callback (uint32_t status, void *data)
{   
    qapi_TLMM_Drive_GPIO(GPIO12, QAPI_GPIO_HIGH_VALUE_E);
    qurt_signal_set(&spi_signal, SPI_DONE);
    qurt_thread_yield();
}
 
qapi_Status_t spi_init(void)
{
    qapi_Status_t    stat;
 
    spi_conf.SPIM_Clk_Polarity      = QAPI_SPIM_CLK_IDLE_LOW_E;
    spi_conf.SPIM_Shift_Mode        = QAPI_SPIM_OUTPUT_FIRST_MODE_E;
    spi_conf.SPIM_CS_Polarity       = QAPI_SPIM_CS_ACTIVE_LOW_E;
    spi_conf.SPIM_CS_Mode           = QAPI_SPIM_CS_KEEP_ASSERTED_E;
    spi_conf.SPIM_Clk_Always_On     = QAPI_SPIM_CLK_NORMAL_E;
    spi_conf.SPIM_Bits_Per_Word     = 8;
    spi_conf.SPIM_Slave_Index       = 0;
    spi_conf.min_Slave_Freq_Hz      = 0;
    spi_conf.max_Slave_Freq_Hz      = 12000000;
    spi_conf.deassertion_Time_Ns    = 0;
    spi_conf.loopback_Mode          = 0;
    spi_conf.hs_Mode                = 1;
 
    stat = qurt_signal_create(&spi_signal);
    if ( stat != QURT_EOK ) return stat;
 
    stat = qapi_SPIM_Open(QAPI_SPIM_INSTANCE_1_E, &spi_handle);
    if (stat != QAPI_OK) return stat;
 
    stat = qapi_SPIM_Enable(spi_handle);
    if (stat != QAPI_OK) return stat;
 
    return QAPI_OK;
}
 
qapi_Status_t spi_transfer(unsigned char *tmt_buf, unsigned char *rcv_buf, int len)
{
    qapi_Status_t    stat;
    
    spi_tx_data.buf_len = len;
    spi_rx_data.buf_len = len;
    spi_tx_data.buf_phys_addr = tmt_buf;
    spi_rx_data.buf_phys_addr = rcv_buf;
 
    qapi_TLMM_Drive_GPIO(GPIO10, QAPI_GPIO_HIGH_VALUE_E);
    qapi_TLMM_Drive_GPIO(GPIO11, QAPI_GPIO_HIGH_VALUE_E);
 
    stat = qapi_SPIM_Full_Duplex(
        spi_handle
        , &spi_conf
        , &spi_tx_data
        , &spi_rx_data
        , spi_callback
        , NULL
    );
 
    qapi_TLMM_Drive_GPIO(GPIO10, QAPI_GPIO_LOW_VALUE_E);
 
    if ( stat != QAPI_OK ) return stat;
 
    qurt_signal_wait (
        &spi_signal, 
        SPI_DONE, 
        QURT_SIGNAL_ATTR_WAIT_ANY | QURT_SIGNAL_ATTR_CLEAR_MASK
    );
 
    qapi_TLMM_Drive_GPIO(GPIO11, QAPI_GPIO_LOW_VALUE_E);
    qapi_TLMM_Drive_GPIO(GPIO12, QAPI_GPIO_LOW_VALUE_E);
    return QAPI_OK;
}
 
  • Up0
  • Down0
yury.gureev
Join Date: 18 Jun 18
Posts: 8
Posted: Fri, 2018-06-22 08:42

Could I program function similar qapi_SPIM_Full_Duplex() myself? For this I need user manual with described low level hardware (SPI registers, interrupt controller registers, DMA controller registers) 

  • Up0
  • Down0
c_rpedad
Profile picture
Join Date: 18 Jun 18
Location: San Jose
Posts: 317
Posted: Fri, 2018-06-22 14:59

We are currently trying to reporduce the scenario locally.
In the mean while can you provide us the graph/scope plots to look into the issue.
 

  • Up0
  • Down0
yury.gureev
Join Date: 18 Jun 18
Posts: 8
Posted: Wed, 2018-06-27 01:04

Hi.

Which email I can send you oscillograms?

  • Up0
  • Down0
yury.gureev
Join Date: 18 Jun 18
Posts: 8
Posted: Fri, 2018-07-13 05:54

Hi Raja,

Did you have any information about my issue?

If it necessary I can send you full project which demonstrate this problem.

Please let me know at what stage the solution is.

Did you manage to reproduce the situation with a delay in entering and exiting the SPI transfer on your equipment?

 

 

  • Up0
  • Down0
c_rpedad
Profile picture
Join Date: 18 Jun 18
Location: San Jose
Posts: 317
Posted: Fri, 2018-07-13 11:18

Hi,

We are able to reproduce the issue locally.
Our design team is currently investigating the issue and provide an update soon.

Korea CE team is working with LGE team on SPI delay issue.

  • Up0
  • Down0
yury.gureev
Join Date: 18 Jun 18
Posts: 8
Posted: Fri, 2019-01-25 07:24

Hi Raja.
From the moment of last comment passed already more than half year.
Maybe you have any new information for my issue?

  • Up0
  • Down0
c_rpedad
Profile picture
Join Date: 18 Jun 18
Location: San Jose
Posts: 317
Posted: Fri, 2019-01-25 10:12

Unfortunately, using our architecture design and qapi_SPIM_Full_Duplex with overhead, it cant be used for the scenario of small amount of data in short intervals of 5us.

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.