MCXN236 FLEXCOMM SPI issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MCXN236 FLEXCOMM SPI issue

933 Views
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.

Labels (1)
Tags (1)
0 Kudos
Reply
5 Replies

916 Views
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 Kudos
Reply

906 Views
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

Tags (1)
0 Kudos
Reply

894 Views
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 Kudos
Reply

879 Views
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
Tags (1)
0 Kudos
Reply

846 Views
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 Kudos
Reply