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.
Hi @seanwu
Regarding speed, you can refer to the MCXN236 data sheet chapter 4.6.2.
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
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
Hi @seanwu
You can refer to my picture to configure the clock.
After my testing, configuring the clock in this way can meet your requirements.
BR
Harry
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 pcsToSckDelay, lastSckToPcsDelay, 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.
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