Increase master SPI speed

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
SamsonLeoMarch
Offline
Last seen:2 years 4 days ago
加入:2018-10-17 17:57
Increase master SPI speed

Hello,
I am currently trying to get my SPI bus to operate at the datasheet listed 48MHz. My understanding is all I need to do is set up my initial clocks with the 96MHz PLL and then in the platform_devices.h just set my divider to the minimum (2). Unfortunately I can't seem to get my spi clock to run faster than 8MHz, which leads me to believe that the clock set up is not changing from 16MHz.

Here is the relevant code:

main.c - system_init()
...
cm_sys_clk_init(sysclk_PLL96);
cm_apb_set_clock_divider(apb_div1);
cm_ahb_set_clock_divider(ahb_div1);
cm_lp_clk_init();
...
cm_sys_clk_set(sysclk_PLL96);
...
plateform_devices.h

#ifdef CONFIG_SPI_DISPLAY
SPI_SLAVE_DEVICE(SPI1, DISPLAY_SPI, HW_GPIO_PORT_4, HW_GPIO_PIN_5, HW_SPI_WORD_9BIT,
HW_SPI_POL_LOW, HW_SPI_PHA_MODE_0, HW_SPI_FREQ_DIV_2, -1);
#endif

Any ideas?

Device:
PM_Dialog
Offline
Last seen:22 hours 37 min ago
工作人员
加入:2018-02-08 11:03
Hi SamsonLeoMarch,

Hi SamsonLeoMarch,

Could you please follow the steps below and let me know if you are able set the SPI bus to operate at 48MHz?

  1. Set the system clock to 96MHz insystem_init()function

cm_sys_clk_init(sysclk_XTAL16M); // instead of sysclk_PLL96

cm_apb_set_clock_divider(apb_div1);

cm_ahb_set_clock_divider(ahb_div1);

cm_lp_clk_init();

/* Set system clock */

cm_sys_clk_set(sysclk_PLL96);

  1. Set the clock source of the SPI peripheral inhw_spi_init()function:

REG_SET_FIELD(CRG_PER, CLK_PER_REG, SPI_CLK_SEL, clk_per_reg_local, 1);// select SPI clock - DIV1 - system clock

  1. Set the clock division for the SPI clock inplatform_devices.hheader file

SPI_SLAVE_DEVICE(SPI1, TEST_SPI, HW_GPIO_PORT_4, HW_GPIO_PIN_0, HW_SPI_WORD_8BIT,

HW_SPI_POL_LOW, HW_SPI_PHA_MODE_0, HW_SPI_FREQ_DIV_2, 0); // SPI at 48 MHz

  1. Define the following macro definition in custom_config_qspi.h header file

#define dg_configUSE_HW_SPI (1)

#define dg_configSPI_ADAPTER (1)

Please try these steps and let me know if your issue has not been fixed.

Thanks, PM_Dialog

SamsonLeoMarch
Offline
Last seen:2 years 4 days ago
加入:2018-10-17 17:57
Thank you! Changing the MUX

Thank you! Changing the MUX for the SPI clock was what did it. I had set up the PLL properly, but was still using the DivN clock instead of the sys_clock for the SPI.

For anyone in the future looking to solve this problem, this is what did it:

Set the clock source of the SPI peripheral in hw_spi_init() function:
REG_SET_FIELD(CRG_PER, CLK_PER_REG, SPI_CLK_SEL, clk_per_reg_local, 1);// select SPI clock - DIV1 - system clock

PM_Dialog
Offline
Last seen:22 hours 37 min ago
工作人员
加入:2018-02-08 11:03
Hi SamsonLeoMarch,

Hi SamsonLeoMarch,

Glad that you figured your issue out. Thanks for your indication and for accepting my answer.

Thanks, PM_Dialog