在使用LPC1768的过程中,系统已经正常跑起来了,UART也可以工作。但是在启用SSP0做SPI主站时,发现初始化后,运行,片先信号也不变低,时针也没有信号输出。MOSI也没有波形。会是设置问题吗?void SPI_Init (void)
{
/* Enable SSPI0 block */
LPC_SC->PCONP |= (1 << 21);
// /* Set SSEL0 as GPIO, output high */
// LPC_PINCON->PINSEL1 &= ~(3 << 0); /* Configure P0.16(SSEL) as GPIO */
// LPC_GPIO0->FIODIR |= (1 << 16); /* set P0.16 as output */
//
// /* Configure other SSP pins: SCK, MISO, MOSI */
// LPC_PINCON->PINSEL0 &= ~(3UL << 30);
// LPC_PINCON->PINSEL0 |= (2UL << 30); /* P0.15: SCK0 */
// LPC_PINCON->PINSEL1 &= ~((3<<2) | (3<<4));
// LPC_PINCON->PINSEL1 |= ((2<<2) | (2<<4)); /* P0.17: MISO0, P0.18: MOSI0 */
/* SSEL is GPIO, output set to high. */
LPC_GPIO1->FIODIR |= (1<<21); /* P1.21 is output */
LPC_GPIO1->FIOPIN |= (1<<21); /* set P1.21 high (SSEL inactiv) */
LPC_PINCON->PINSEL3 &= ~(3<<12); /* P1.21 SSEL (used as GPIO) */
/* SCK, MISO, MOSI are SSP pins. */
LPC_PINCON->PINSEL3 &= ~(3UL<<8); /* P1.20 cleared */
LPC_PINCON->PINSEL3 |= (3UL<<8); /* P1.20 SCK0 */
LPC_PINCON->PINSEL3 &= ~((3<<14) | (3<<16)); /* P1.23, P1.24 cleared */
LPC_PINCON->PINSEL3 |= ((3<<14) | (3<<16)); /* P1.23 MISO0, P1.24 MOSI0 */
/* Configure SSP0_PCLK to CCLK(100MHz), default value is CCLK/4 */
LPC_SC->PCLKSEL1 &= ~(3 << 10);
LPC_SC->PCLKSEL1 |= (1 << 10); /* SSP0_PCLK=CCLK */
/* 8bit, SPI frame format, CPOL=0, CPHA=0, SCR=0 */
LPC_SSP0->CR0 = (0x07 << 0) | /* data width: 8bit*/
(0x00 << 4) | /* frame format: SPI */
(0x00 << 6) | /* CPOL: low level */
(0x00 << 7) | /* CPHA: first edge */
(0x00 << 8); /* SCR = 0 */
/* Enable SSP0 as a master */
LPC_SSP0->CR1 = (0x00 << 0) | /* Normal mode */
(0x01 << 1) | /* Enable SSP0 */
(0x00 << 2) | /* Master */
(0x00 << 3); /* slave output disabled */
/* Configure SSP0 clock rate to 400kHz (100MHz/250) */
SPI_ConfigClockRate (SPI_CLOCKRATE_LOW);
/* Set SSEL to high */
SPI_CS_High ();
|