MCXN236 FLEXCOMM SPI issue

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

MCXN236 FLEXCOMM SPI issue

947件の閲覧回数
seanwu
Contributor IV

Dear sir,

I am using lpspi_interrupt_b2b_master, and lpspi_interrupt_b2b_slave examples in MCXN236 SDK 2.16.00 to test SPI function.

I want to check whether it can run 20MHz. But when I set #define TRANSFER_BAUDRATE to 20000000. The data transfer will be error.

Could you please help to check whether FLEXCOMM SPI can run 20MHz, and how to set?

THanks.

BR,

Sean Wu.

ラベル(1)
タグ(1)
0 件の賞賛
返信
5 返答(返信)

930件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @seanwu 

Regarding speed, you can refer to the MCXN236 data sheet chapter 4.6.2.

 

Harry_Zhang_0-1742207698376.png

After you set #define TRANSFER_BAUDRATE to 20000000.

You also need to two factors:

1. Peripheral Clock Configuration: The SPI baud rate is derived from the peripheral clock. Ensure that the peripheral clock is set appropriately to achieve the desired SPI speed.

2. Baud Rate Divisor: The SPI baud rate is determined by dividing the peripheral clock by a specific divisor. Selecting the correct divisor is crucial for achieving the desired baud rate.

 

BR

Harry

0 件の賞賛
返信

920件の閲覧回数
seanwu
Contributor IV

Dear @Harry_Zhang ,

This is my setting. Is it OK?

CLOCK_SetClkDiv(kCLOCK_DivFlexcom3Clk, 1u);

CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM3);

 

Thanks.

BR,

Sean Wu

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

908件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @seanwu 

You can refer to my picture to configure the clock.

Harry_Zhang_0-1742292618248.png

After my testing, configuring the clock in this way can meet your requirements.

BR

Harry

0 件の賞賛
返信

893件の閲覧回数
seanwu
Contributor IV

Dear @Harry_Zhang ,

Thanks for your help. I try it as your seeting, and it can run 20MHz. But the main  clock will reduce to 120Hz. Does it effect performance?

And I have another question of delay time of pcsToSckDelaylastSckToPcsDelay, and betweenTransferDelay.

How do I set the value like below code? 

masterConfig.pcsToSckDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U);

masterConfig.lastSckToPcsDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U);

masterConfig.betweenTransferDelayInNanoSec = 1000000000U / (masterConfig.baudRate * 2U);

 

And in RM, there is a example, but I don't know why.

seanwu_0-1742346631837.png
 
Thanks.
BR,
Sean Wu
タグ(1)
0 件の賞賛
返信

860件の閲覧回数
Harry_Zhang
NXP Employee
NXP Employee

Hi @seanwu 

"But the main  clock will reduce to 120Hz. Does it effect performance?"

I'm just giving you a demonstration, you can adjust the clock according to your needs.

"How do I set the value like below code?"

I think it depends on the slave device’s timing specs.

BR

Harry

0 件の賞賛
返信