我配的在MINI58下SPI输出用逻辑分析仪测不到波形,大家看下有错误吗
其中串口能用软件看到打印输出,但蕊片MOSI、MISO口测不到波形
int main(void)
{
/* Init System, IP clock and multi-function I/O */
SYS_Init();
/* Init UART for printf */
UART_Init();
/* Init SPI */
SPI_Init();
printf("\n\n");
printf("+----------------------------------------------------------------------+\n");
printf("| SPI Driver Sample Code |\n");
printf("+----------------------------------------------------------------------+\n");
printf("\n");
printf(" Please Connect:\n");
printf(" P0.5 MOSI <--> P0.6 MISO \n");
//SpiLoopbackTest();
while(1)
{
SPI_READ_RX(SPI0);
SPI_WRITE_TX(SPI0, 0xaa);
printf(" P0.5 MOSI <--> P0.6 MISO \n");
}
// return 0;
}
void SYS_Init(void)
{
/* Unlock protected registers */
SYS_UnlockReg();
/* Read User Config to select internal high speed RC */
//SystemInit();
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
/* Enable external 12MHz XTAL, HIRC */
// CLK->PWRCTL |= CLK_PWRCTL_XTL12M | CLK_PWRCTL_HIRCEN_Msk;
/* Waiting for clock ready */
// CLK_WaitClockReady(CLK_STATUS_XTLSTB_Msk | CLK_STATUS_HIRCSTB_Msk);
/* Switch HCLK clock source to XTL */
// CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_XTAL,CLK_CLKDIV_HCLK(1));
/* STCLK to XTL STCLK to XTL */
// CLK_SetSysTickClockSrc(CLK_CLKSEL0_STCLKSEL_XTAL);
/* Enable IP clock */
CLK_EnableModuleClock(UART0_MODULE);
CLK_EnableModuleClock(SPI0_MODULE);
SystemCoreClockUpdate();
/* Select IP clock source */
// CLK_SetModuleClock(UART0_MODULE,CLK_CLKSEL1_UARTSEL_XTAL,CLK_CLKDIV_UART(1));
//CLK_SetModuleClock(SPI0_MODULE,CLK_CLKSEL1_SPISEL_XTAL,0);
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set P1 multi-function pins for UART RXD and TXD */
SYS->P5_MFP = SYS_MFP_P51_UART0_RXD | SYS_MFP_P50_UART0_TXD;
/* Setup SPI multi-function pin */
SYS->P0_MFP |= SYS_MFP_P04_SPI0_SS | SYS_MFP_P05_SPI0_MOSI | SYS_MFP_P06_SPI0_MISO | SYS_MFP_P07_SPI0_CLK;
/* Lock protected registers */
SYS_LockReg();
/* Update System Core Clock */
// SystemCoreClockUpdate();
}
void UART_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init UART */
/*---------------------------------------------------------------------------------------------------------*/
/* Reset IP */
SYS_ResetModule(UART0_RST);
/* Configure UART and set UART Baudrate */
UART_Open(UART0, 115200);
}
void SPI_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init SPI */
/*---------------------------------------------------------------------------------------------------------*/
/* Configure as a master, clock idle low, falling clock edge Tx, rising edge Rx and 32-bit transaction */
/* Set IP clock divider. SPI clock rate = 2MHz */
SPI_Open(SPI, SPI_MASTER, SPI_MODE_0, 32, 2000000);
/* Enable the automatic hardware slave select function. Select the SS pin and configure as low-active. */
SPI_EnableAutoSS(SPI, SPI_SS, SPI_SS_ACTIVE_LOW);
}
|