Content originally posted in LPCWare by krhodesnb on Mon Feb 03 18:21:07 MST 2014
How do I change the clock frequency of an SSP channel, once it is running? This is required to support a SPI SSD interface. It needs to first be set to 400kHz, then change to 15MHz.
In the code snippet below, I show how I try to change the clock frequency, but when we look at it on a scope, it stays at 400kHz. We tried to not call IP_SSP_Set_Mode and IP_SSP_SetFormat, but no change.
Initialization:
#define SDC_SSI_DEVICE_BASE LPC_SSP0
#define SSD_LOW_SPEED_CLOCK_FREQ 400000
#define SSD_HIGH_SPEED_CLOCK_FREQ 1500000
IP_SSP_Set_Mode(SDC_SSI_DEVICE_BASE, SSP_MODE_MASTER);
IP_SSP_SetFormat(SDC_SSI_DEVICE_BASE, SSP_BITS_8, SSP_FRAMEFORMAT_SPI, SSP_CLOCK_MODE1);
Chip_SSP_SetBitRate(SDC_SSI_DEVICE_BASE, SSD_LOW_SPEED_CLOCK_FREQ);
Chip_Clock_Enable(CLK_MX_SSP0);
Chip_SSP_Enable(SDC_SSI_DEVICE_BASE);
Code to change the frequency:
Chip_SSP_Disable(SDC_SSI_DEVICE_BASE);
Chip_Clock_Disable(CLK_MX_SSP0);
IP_SSP_Set_Mode(SDC_SSP_BASE, SSP_MODE_MASTER);
IP_SSP_SetFormat(SDC_SSP_BASE, SSP_BITS_8, SSP_FRAMEFORMAT_SPI, SSP_CLOCK_MODE1);
Chip_SSP_SetBitRate(SDC_SSP_BASE, SSD_HIGH_SPEED_CLOCK_FREQ);
Chip_Clock_Enable(CLK_MX_SSP0);
Chip_SSP_Enable(SDC_SSI_DEVICE_BASE);
Thanks.