Forums - QCA4020 SPI full duplex not working

4 posts / 0 new
Last post
QCA4020 SPI full duplex not working
akshay.b
Join Date: 2 Aug 19
Posts: 62
Posted: Tue, 2019-11-05 22:03

Hello,

We are not able to establish full duplex communication for SPI.

SPI tx is working completly file but when it comes to read a register from SPI slave the write and read operation is not working for single CS operation.

We want to perform read register operation as below

<CS LOW> <REG ADDRESS MSB> <REG ADDRESS LSB> <READ_REG_BYTE 1>  <READ_REG_BYTE 2>  <READ_REG_BYTE 3>  <READ_REG_BYTE 4> <CS HIGH>

To achieve this we have written following spi full duplex function

spi_device_config.SPIM_Clk_Polarity =  QAPI_SPIM_CLK_IDLE_LOW_E;
  spi_device_config.SPIM_Shift_Mode = QAPI_SPIM_INPUT_FIRST_MODE_E;
  spi_device_config.SPIM_CS_Polarity = QAPI_SPIM_CS_ACTIVE_LOW_E;
  spi_device_config.SPIM_CS_Mode = QAPI_SPIM_CS_KEEP_ASSERTED_E;
  spi_device_config.SPIM_Clk_Always_On =  QAPI_SPIM_CLK_NORMAL_E;
  spi_device_config.SPIM_Bits_Per_Word = 8;
  spi_device_config.SPIM_Slave_Index = 0;
  spi_device_config.min_Slave_Freq_Hz = 0;
  spi_device_config.max_Slave_Freq_Hz = 10000000;
  spi_device_config.deassertion_Time_Ns = 0;
  spi_device_config.loopback_Mode = loopback_mode;
  spi_device_config.hs_Mode = 0;
 

tx_info_temp.buf_len = 2; 
rx_info_temp.buf_len = 4;

write_register_data = (uint8 *) malloc (2);
write_register_data[0] = 0x00;
write_register_data[1] = 0x08;

read_register_data  = (uint8 *) malloc (4);

tx_info_temp.buf_phys_addr = write_register_data;
 rx_info_temp.buf_phys_addr = read_register_data;
 

qapi_SPIM_Full_Duplex(hSPI, &spi_device_config, &tx_info, &rx_info_temp, spi_io_complete_cb, NULL);

//calling wait function.

The code is executing without any error messages, but when we view it on logic analyzer
MOSI 0x00 0x08 0x00 0x00
MISO 0xFF 0xFF  0xFF  0xFF 

Means total 6 byte transaction should be there but only 4 bytes are seen and CS goes high after that.

Please suggest a solution for this.

Thank You,

Akshaay24

  • Up0
  • Down0
jaydenk
Join Date: 21 Jun 18
Posts: 64
Posted: Wed, 2019-11-06 15:28

Hi Akshaay24,

What should be used between tx_info and tx_info_temp in the transaction.
It looks you're configuring tx_info_temp but using tx_info in qapi_SPIM_Full_Duplex().

Thanks
BR,
Jayden

  • Up0
  • Down0
akshay.b
Join Date: 2 Aug 19
Posts: 62
Posted: Wed, 2019-11-06 22:08

Hi Jayden,

It was a typo error, the SPI is actually configured for tx_info_temp. 

qapi_SPIM_Full_Duplex(hSPI, &spi_device_config, &tx_info_temp, &rx_info_temp, spi_io_complete_cb, NULL);

what can be the issue behind this. The actual output i should get on MISO is 0x12 0x34 0x56 0x78.

Its only receiving 2 bytes insted of 4 and that is 0xFF.

Can anyone suggest a solution for why fullduplex is not working on my silex board for QCA4020.

Thank you,

Akshaay

  • Up0
  • Down0
c_rpedad
Profile picture
Join Date: 18 Jun 18
Location: San Jose
Posts: 317
Posted: Thu, 2019-11-21 18:20

I have tried to set tx_buf_info to 2bytes, rx_buf_info to 4bytes and connected MOSI to MISO  for verifying if the same data is received.Since your rx_length is 4, the CLK with consider maximum length of MOSI/MISO which is 4 in this case ans CS will assert after 4 bytes.

Below is my configuration:

config.SPIM_Clk_Polarity = QAPI_SPIM_CLK_IDLE_LOW_E;
config.SPIM_Shift_Mode = QAPI_SPIM_INPUT_FIRST_MODE_E;
config.SPIM_CS_Polarity = QAPI_SPIM_CS_ACTIVE_LOW_E;
config.SPIM_CS_Mode = QAPI_SPIM_CS_KEEP_ASSERTED_E;
config.SPIM_Clk_Always_On = QAPI_SPIM_CLK_NORMAL_E;
config.SPIM_Bits_Per_Word = 8;
config.SPIM_Slave_Index = 0;
config.min_Slave_Freq_Hz = 0;
config.max_Slave_Freq_Hz = 3000000;
config.deassertion_Time_Ns = 0;
config.loopback_Mode = en_loopback;
config.hs_Mode = 0;
 
tx_info_temp.buf_len = 2; 
rx_info_temp.buf_len = 4;

I am attaching MOSI/MISO/CS/CLK plot for referance :
  • 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.