Hi, Vava
If the SPI clock frequency is not what you expected, maybe the code somewhere has changed the SPI clock setting, but we can track the SPI clock source. I suppose you do not set up the MCG, you use the default clock for the core and the peripherals, in the case, the core runs in 25MHz, the bus clock is about 12.5mHz, the SPI use the bus clock as the it's own clock.
You can reduce the clock by setting the BR bits in SPIx_CTARn register.
You can write the register with the code directly:
SPI0_CTAR0&=~(0x0F);
SPI0_CTAR0|=0x08;
The SPI 0 clock will be divided by 512.
I have checked the SPI MQX code, theer is code to set the spi clock frequency:
param = 500000;
printf ("Changing the baud rate to %d Hz ... ", param);
if (SPI_OK == ioctl (spifd, IO_IOCTL_SPI_SET_BAUD, ¶m))
{
printf ("OK\n");
}
else
{
printf ("ERROR\n");
}
/* Display baud rate */
printf ("Current baud rate ... ");
if (SPI_OK == ioctl (spifd, IO_IOCTL_SPI_GET_BAUD, ¶m))
{
printf ("%d Hz\n", param);
}
else
{
printf ("ERROR\n");
}
You can change the param parameter to change the clock setting.
Hope it can help you.
BR
Xiangjun rong