According to the i.MX 7Dual Family of Applications Processors Datasheet, Rev. 5, 07/2017 at page 10, the ecSPI data rate can reach 52 Mbit/s.
I started with the master polling ecspi example. I could easyily change the bus frequency up to 24MHz. But if I set a baudrate value higher than 24000000, the SPI SCLK signal frequency keeps stuck at 24MHz (measured electrically).
ecspi_init_config_t initConfig = {
.baudRate = 24000000,
.mode = ecspiMasterMode,
.burstLength = ECSPI_MASTER_BURSTLENGTH,
.channelSelect = BOARD_ECSPI_CHANNEL,
.clockPhase = ecspiClockPhaseSecondEdge,
.clockPolarity = ecspiClockPolarityActiveHigh,
.ecspiAutoStart = ECSPI_MASTER_STARTMODE
};
By the way to make it work that fast, I had to set SRE and DSE bits.
void configure_ecspi_pins(ECSPI_Type* base)
{
...
/* pad control */
IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL = IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_PE_MASK |
IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_PS(0) | /* pull down */
IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_DSE(3) |
IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_SRE_MASK |
IOMUXC_SW_PAD_CTL_PAD_I2C2_SCL_HYS_MASK;
I tried to change to change the clock source. But It doesn’t affect the SCLK frequency.
uint32_t pre = -1;
uint32_t post = -1;
uint32_t root = -1;
//CCM_SetRootMux(CCM, ccmRootEcspi1, ccmRootmuxEcspiSysPllDiv2);
CCM_SetRootMux(CCM,ccmRootEcspi1 , ccmRootmuxEcspiSysPllPfd4);
CCM_SetRootDivider(CCM , ccmRootEcspi1, 1, 1);
CCM_GetRootDivider(CCM, ccmRootEcspi1, &pre, &post);
root = CCM_GetRootMux(CCM, ccmRootEcspi1);
ECSPI_SetSampClockSource(BOARD_ECSPI_BASEADDR, 0);
I’m not sure but I assume there is a mistake in the documentation or in the BSP. They contradict each other. The ecspi clock id is 102 in the FreeRTOS code and number 120 in i.MX 7 Dual Applications Processor Reference Manual. So I’m a bit confused.
The code in platform/drivers/inc/ccm_imx7d.h
enum _ccm_root_control
{
...
ccmRootEcspi1 = (uint32_t)(&CCM_TARGET_ROOT102), /*!< ECSPI1 Clock control name.*/
ccmRootEcspi2 = (uint32_t)(&CCM_TARGET_ROOT103), /*!< ECSPI2 Clock control name.*/
ccmRootEcspi3 = (uint32_t)(&CCM_TARGET_ROOT104), /*!< ECSPI3 Clock control name.*/
ccmRootEcspi4 = (uint32_t)(&CCM_TARGET_ROOT105), /*!< ECSPI4 Clock control name.*/
...
};
The clock root table that show we can even reach 80 MHz.
i.MX 7Dual Applications Processor Reference Manual p. 543
[upload|5BqM3QcfHgeKrPK+7151V+SSR58=]
The id 102 doesn’t belong to the ecspi clock.
i.MX 7Dual Applications Processor Reference Manual p. 581
[upload|z49EJ1Uld8XG8eJ79bEfubq0mqI=]
Actually the ecspi clock belongs to the id 120.
i.MX 7Dual Applications Processor Reference Manual p.582
So I’m wondering, whether you have a solution to get a SPI frequency above 24MHz ? I gave a modified copy of examples/imx7_colibri_m4/driver_examples/ecspi/ecspi_polling/master/main.c which I tried to change the SPI clock.
Thanks in advance,
Arnaud