在对SPI进行初始化时,配置SPIFMT寄存器,设置时钟频率为 ***->cfgFmt->freq=2000000,
#define SPI0_MOD_CLK 100000000
prescaler = ((SPI0_MOD_CLK / ***->cfgFmt->freq) – 1) & 0xFF);//100000000
但是实际测量的SPI时钟频率为3.8Mhz,这是什么原因。
15-8 | PRESCALE | 2h-FFh | SPI prescaler. It determines the bit transfer rate if the SPI is the network master and is directly derived from the SPI module clock. If the SPI is configured as slave, PRESCALE needs to be configured to a valid value, but PRESCALE is ignored. The clock rate can be calculated as: SPI clock frequency = SPI module clock/(PRESCALE + 1) Note: PRESCALE values less than 2h are not supported |
PRESCALE配置时,SPI module clock是直接定义还是需要配置其他时钟?
Nancy Wang:
不是直接定义的,要计算的。您是用的spi0还spi1?spi0 module clock是PLL0_SYSCLK2,SPI1 module clock是PLL1_SYSCLK2。参考datasheet Figure 6-9. PLL Topology。
另外您是用的开发板吗?可以参考GEL文件里面clock的相关配置。