About QN908x SPI slave

cancel
Showing results for 
Search instead for 
Did you mean: 

About QN908x SPI slave

214 Views
Contributor II

Test environment:
- spi slave: QN9080-DK board
- spi master: ti cc2640r2 development kit

SPI Settings
- data length: 8bit
- clock hz: 400kHz to 4MHz
- source code: modified qn908xcdk_driver_examples_spi_interrupt_transfer example

The spi test was conducted in the above environment.
From 400kHz to 2MHz, the reception was successful without missing data.
The problem is that at 4 MHz, the data is broken.

See the attachment for the SPI waveform.

Question 1
a. Can I use 4Mbps as an interrupt method?
b. Is 4Mbps reception possible using DMA?

Question 2
a. Is it possible to receive continuous data without interruption by DMA (SPI Slave) method?
   - Master constantly transmits data at 2Mbps.
   - DMA buffer size is 256.
   - When tested using the example, data is missing because of the time it takes to operate the DMA again after the DMA reception is completed.

Labels (1)
  • QN

9 Replies

9 Views
Contributor II

Another Question!

Two examples of QN909xcdk are combined.
1.qn908xcdk_driver_examples_spi_interrupt_b2b_slave
2. qn908xcdk_driver_examples_spi_dma_transfer

The two projects were combined and coded to transfer using interrupts or DMA.

What I want is to implement an SPI slave, to do this, the master part was removed from the second project.

The SPI PIN connection is shown below.
PA5-MISO
PA4-MOSI
PA30-SCK
PA3-SSEL

The main SPI configuration code is shown below.
#define EXAMPLE_SPI_SLAVE SPI0
#define EXAMPLE_SPI_SLAVE_IRQ FLEXCOMM2_IRQn
#define EXAMPLE_SPI_SSEL 0
#define SPI_SLAVE_IRQHandler FLEXCOMM2_IRQHandler
#define EXAMPLE_SLAVE_SPI_SPOL (kSPI_SpolActiveAllLow | kSPI_Spol2ActiveHigh | kSPI_Spol3ActiveHigh)

SPI_SlaveGetDefaultConfig (& slaveConfig);
/ * SPI slave must be enabled afer DMA is ready to transfer data * /
slaveConfig.enableSlave = false;
slaveConfig.dataWidth = kSPI_Data16Bits;
slaveConfig.sselPol = (spi_spol_t) EXAMPLE_SLAVE_SPI_SPOL;
SPI_SlaveInit (EXAMPLE_SPI_SLAVE, & slaveConfig);

SPI Master is implemented with other boards.

Waveform

waveform.PNG


Questions
When operating SPI Slave after setting SPI as above, data is received when operating based on Interrupt.
However, DMA-based operation does not receive data.
I want to know why.

My purpose is to implement SPI Slave using DMA.

The entire project is attached.

0 Kudos

9 Views
NXP TechSupport
NXP TechSupport

Hi Jinjee,

 

If you use the DMA example in one board, connecting SPI0 and SPI1 to each other, does the code work?

 

Is the execution ever reaching the Slave Callback? Can you see any activity on the transmission lines?

 

Please let me know of your findings.

 

Best regards,

Sebastian

0 Kudos

9 Views
Contributor II

Hi Sebastian,

I deleted the master code part of the DMA example and used only the slave part. I also merged the interrupt slave b2b example so that I could test interrupts and DMA on the same setup.

The test was carried out as follows.
1. Using Flexcomm3
Settings
#define EXAMPLE_SPI_SLAVE SPI1
#define EXAMPLE_SPI_SLAVE_IRQ FLEXCOMM3_IRQn
#define EXAMPLE_SPI_SSEL 1
#define SPI_SLAVE_IRQHandler FLEXCOMM3_IRQHandler
#define EXAMPLE_SLAVE_SPI_SPOL (kSPI_SpolActiveAllLow | kSPI_Spol0ActiveHigh | kSPI_Spol2ActiveHigh | kSPI_Spol3ActiveHigh)

SPI pin number
PA17-MISO, PA16-MOSI, PA15-SCK, PA13-SSEL
DMA: Normal Operation
Interrupt: Normal Operation

2. Using Flexcomm2
Settings
#define EXAMPLE_SPI_SLAVE SPI0
#define EXAMPLE_SPI_SLAVE_IRQ FLEXCOMM2_IRQn
#define EXAMPLE_SPI_SSEL 0
#define SPI_SLAVE_IRQHandler FLEXCOMM2_IRQHandler
#define EXAMPLE_SLAVE_SPI_SPOL (kSPI_SpolActiveAllLow | kSPI_Spol2ActiveHigh | kSPI_Spol3ActiveHigh)

SPI pin number
PA5-MISO, PA4-MOSI, PA30-SCK, PA3-SSEL

Interrupt: Normal Operation
DMA: not working

pastedImage_1.png

Q1. I wonder if DMA doesn't work only when I use pins 3, 4, 5, and 30 on Flexcomm2.

Q2. I ask for confirmation that my SPI settings are correct.

The full code is attached.

0 Kudos

9 Views
NXP TechSupport
NXP TechSupport

Hi Jinjee,

The DMA SPI transfer example is working correctly, however, the pin connections described on the readme file are incorrect.

pastedImage_1.png

pastedImage_2.png

The CLK pins are actually J7 pins 6 and 10, instead of 5 and 9. Could you please check that the correct CLK pin for flexcomm is being used?

Also, could you please check that you're not accidentally removing special configuration for Flexcomm2? This Flexcomm module can either be configured as an I2C or SPI peripheral, so maybe some configuration is being erased erroneously.

Please let me know if you continue to have issues.

Best regards,

Sebastian

0 Kudos

9 Views
Contributor II

I think you misunderstood the point of my question.

The point of my question is I want to know why SPI using Interrupt work but DMA does not work on the same pin configuration.

Rewrite the pin configuration.

2.Using Flexcomm2
Settings
#define EXAMPLE_SPI_SLAVE SPI0
#define EXAMPLE_SPI_SLAVE_IRQ FLEXCOMM2_IRQn
#define EXAMPLE_SPI_SSEL 0
#define SPI_SLAVE_IRQHandler FLEXCOMM2_IRQHandler
#define EXAMPLE_SLAVE_SPI_SPOL (kSPI_SpolActiveAllLow | kSPI_Spol2ActiveHigh | kSPI_Spol3ActiveHigh)

SPI pin number
PA5-MISO, PA4-MOSI, PA30-SCK, PA3-SSEL

Interrupt: work
DMA: not working

0 Kudos

9 Views
NXP TechSupport
NXP TechSupport

Hi Jinjee!

Could you please try changing the DMA channel definitions to the following?

#define EXAMPLE_SPI_SLAVE_RX_CHANNEL 4
 
#define EXAMPLE_SPI_SLAVE_TX_CHANNEL 5‍‍‍

Since you're using flexcomm2, you need to accordingly change the DMA channels, because channels 6 and 7 correspond to flexcomm3.

Please let me know if you continue to have issues.

Best regards,

Sebastian

0 Kudos

9 Views
Contributor II

Thanks Sebastian!

It's working.

I didn't know that the DMA channel and flexcomm were connected.
I found this information on page 124 at user manual. thank you for helping.

9 Views
NXP TechSupport
NXP TechSupport

Hi Jinjee, I hope you're doing well!

 

Fully automatic slave operation is supported by the Flexcomm module configured as I2C slave, but it has some limitations. In I2C there are some control bits that must be enabled for this mode to work properly.

 

While SPI does support a DMA controlled slave mode, it cannot be continuous as the I2C mode is.

Data is being transmitted at fast speeds, and the DMA takes some time to continue operation after a transfer, so it would be expected that the MCU loses some data.

 

You could try implementing some delays on your master device, if possible, or trying to empty the buffer.

 

If you need more information about DMA operation with SPI, could you please check chapter 22 of UM11023 (the User Manual for QN908x devices), here?

 

Please let me know if you have any other questions.

 

Best regards,

Sebastian

0 Kudos

9 Views
Contributor II

Question 1 is my mistake. This is caused by not matching the phase and polarity of the SPI, so there is no need to answer.

0 Kudos