Reducing CS Low Time Before Starting SCLK in SPI Communication

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Reducing CS Low Time Before Starting SCLK in SPI Communication

5,822件の閲覧回数
mehul_dabhi
Contributor III

I am using the i.MX8MP SoC and have configured the SPI frequency to 25 MHz and am writing 24-bit data. However, I am observing an extended CS (Chip Select) low time of approximately 2.2 µs before the SCLK (Serial Clock) starts, as seen in the captured image.

What steps can I take to reduce the CS low time before the SCLK begins? Any guidance or suggestions?

タグ(1)
0 件の賞賛
返信
19 返答(返信)

4,549件の閲覧回数
mehul_dabhi
Contributor III

Hi @pengyong_zhang ,

Also, when using HW CS pin, we are observing the high CS idle time of around ~3.4us
I am attaching the snap for the same; kindly look into it.

 

 




0 件の賞賛
返信

5,129件の閲覧回数
pengyong_zhang
NXP Employee
NXP Employee

Hi @mehul_dabhi 

I think if you must use DMA transfer, You can refer the spidev_test, It depends on your test code. And BTW, i will in spring festival for a long time, If you have any question, you can create a new ticket.

B.R

0 件の賞賛
返信

5,034件の閲覧回数
mehul_dabhi
Contributor III

Continued discussion at link

0 件の賞賛
返信

5,510件の閲覧回数
pengyong_zhang
NXP Employee
NXP Employee

Hi @mehul_dabhi 

You can disable the DMA to implementation for your needs.

pengyong_zhang_0-1736300673545.png

B.R

5,465件の閲覧回数
mehul_dabhi
Contributor III

Hi @pengyong_zhang,

Thanks for the timely response. I will test this and report the results here.

Regards,

Mehul

0 件の賞賛
返信

5,439件の閲覧回数
mehul_dabhi
Contributor III

Hi @pengyong_zhang,

I have faced a setback for my hardware setup and I will be on leave for next week. So my response to your suggestion will be a bit delayed but will surely post the results whenever I test it.

 

Thanks,

Mehul

0 件の賞賛
返信

5,146件の閲覧回数
mehul_dabhi
Contributor III

Hi @pengyong_zhang,

I followed your suggestion and disabled DMA as a result I have been able to get the delay lowered down to around ~500ns for 1MHz I have attached the snap of it.

mehul_dabhi_1-1737374746705.jpeg

 

But I have following questions :

  1. How does enabling DMA causes the CS pin to go high after each byte transfer?
  2. The project that I am working on also has ADC interfaced to SPI (not the same bus as DAC). So communicating continuously to both ADC and DAC for high sample rates will burden the CPU a lot. For this reason I was thinking of forcing DMA for every transaction over SPI. With your current solution I will not be able to do that. So, is there any way to get this issue resolved with DMA enabled? If not, what can I do to lower the burden from CPU?

 

Thanks,
Mehul

IMX8MPLUS 

0 件の賞賛
返信

5,535件の閲覧回数
pengyong_zhang
NXP Employee
NXP Employee

Hi @mehul_dabhi 

Working on your this request. and will give you the feedback ASAP.

B.R

0 件の賞賛
返信

5,525件の閲覧回数
mehul_dabhi
Contributor III

Ok @pengyong_zhang, I will be looking forward for your response

Thanks

0 件の賞賛
返信

5,640件の閲覧回数
pengyong_zhang
NXP Employee
NXP Employee

Hi @mehul_dabhi 

I think you are right. you can config the register SS_CTL bit to meet your requirement. But i think you should keep ECSPIx_CONREG[SMC] clear, And writing a 1 to XCH bit starts one SPI burst or multiple SPI bursts according to the SPI SS Wave Form Select (SS_CTL)

B.R

0 件の賞賛
返信

5,616件の閲覧回数
mehul_dabhi
Contributor III

Thanks for the response @pengyong_zhang.

I have configured following register bits :

SS_CTL = 0
SMC =0 (also tried setting it to 1 and handle XCH accordingly)
BURST_LENGTH = 7 (for 8-bits and even tried setting it to 0x017 for 24 bits)

With the above configurations I still am facing problem of CS assertion at every byte transfer, so what have I done wrong here and have I missed something within the configurations?

Thanks,
Mehul

タグ(2)
0 件の賞賛
返信

5,538件の閲覧回数
mehul_dabhi
Contributor III

Hi @pengyong_zhang 

I still am facing the issue and have tried the above configurations for trying to make it work. I could use some guidance about what I am doing wrong here to resolve this issue.

Thanks,

Mehul

タグ(1)
0 件の賞賛
返信

5,689件の閲覧回数
pengyong_zhang
NXP Employee
NXP Employee

Hi @mehul_dabhi 

But what happens is I am trying to transmit 24 bits of data and CS should remain low until all the bits are transferred rather the CS goes high after each transfer of 8-bit

>>>As long as you don't use gpio to control cs, it's like this. It is normal. 

B.R

0 件の賞賛
返信

5,680件の閲覧回数
mehul_dabhi
Contributor III

Hi @pengyong_zhang 

I want to write samples to DAC continuously over SPI having data and register command lengths of 24 bits. The max frequency supported by DAC is 35MHz and I want to write counts at every us interval.

Now when I use gpio to control CS (i.e. cs-gpios property in dts) I observe a delay of ~2us between CS assertion and SCLK availability for data transfer.

If I use native CS (i.e. do not mention cs-gpios in dts) it goes high for every bits per word transfer (in my case 8-bits).

Also as per reference manual I should be able to transmit 512 bytes in single transfer, but in my case I am unable to transmit 3-bytes in single transfer.

Then how can I achieve my requirement? What is your suggestion/guidance?

FYI I am working on kernel version 6.1.36

Thanks,
Mehul

0 件の賞賛
返信

5,671件の閲覧回数
mehul_dabhi
Contributor III

@pengyong_zhang, I could not edit my previous reply so replying on my previous comment.

I am interfacing DAC to ecspi2 and I have gathered following understanding from the reference manual of imx8mp.

mehul_dabhi_0-1735810462438.png


With the configuration of ECSPIx_CONREG[SMC] =1, I can immediately start the SPI transfer once the data is in TxFIFO and with ECSPIx_CONFIGREG[SS_CTL] = 0, the data should be transferred without the asserting the CS between the consecutive bursts until the ECSPIx_CONREG[BURST_LENGTH] is transferred . Below are the snaps for this.

mehul_dabhi_1-1735810702247.png   

mehul_dabhi_3-1735811236374.png

 



Based on this theory we have selected and designed the hardware. So as I mentioned in my previous comment what can be done to meet my requirement? Or is there some problem with the reference manual? Or have I misunderstood something?

 



 

0 件の賞賛
返信

5,743件の閲覧回数
pengyong_zhang
NXP Employee
NXP Employee

Hi @mehul_dabhi 

Firstly, Do not use GPIO as CS ctrl, Then you can use the  ECSPIx_PERIODREG (CSD_CTL) control the Chip Select Delay.

B.R

0 件の賞賛
返信

5,734件の閲覧回数
mehul_dabhi
Contributor III

Hi @pengyong_zhang 

I removed the cs-gpios property from the device tree node and have been able to bring down the delay. But what happens is I am trying to transmit 24 bits of data and CS should remain low until all the bits are transferred rather the CS goes high after each transfer of 8-bit. I also tried configuring cs_change to 0 from spi_transfer structure but no improvement with that too. Below is the attached snap.

mehul_dabhi_0-1735639636977.jpeg



Thanks 
Mehul

0 件の賞賛
返信

5,760件の閲覧回数
mehul_dabhi
Contributor III

Hi @pengyong_zhang ,

I have attached the the waveform image below, the signal in yellow is CS gpio and the blue one is SCK of SPI.

 

I also tried configuring the cs_setup delay from spi_device structure but it too does not lead to any improvements. I have to write around 300K samples in a sec to a DAC and if this delay persists this will become an impossible thing for me to do.

Thanks,

Mehul

cs_low_time_with_sclk.png

 

0 件の賞賛
返信

5,768件の閲覧回数
pengyong_zhang
NXP Employee
NXP Employee

HI @mehul_dabhi 

Please share your captured image.

Thanks!

0 件の賞賛
返信