MCXN236 FLEXCOMM SPI issue

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MCXN236 FLEXCOMM SPI issue

948 次查看
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 回复数

931 次查看
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 项奖励
回复

921 次查看
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 项奖励
回复

909 次查看
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 项奖励
回复

894 次查看
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 项奖励
回复

861 次查看
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 项奖励
回复