本帖最后由 apple163 于 2016-6-25 10:06 编辑
如题,
是我的代码配置有问题?
那么这种情况怎么修复呢?不能因为用户代码有错误就终身锁死了吧?
我焊接了外部时钟,还是无法链接,我的代码确实是操作错了时钟源,但是难道这样就是死刑?
void SYS_Init(void)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
/* Unlock protected registers */
SYS_UnlockReg();
/* Enable IRC22M clock */
CLK->PWRCON &= ~CLK_PWRCON_IRC22M_EN_Msk;
CLK->PWRCON |= CLK_PWRCON_IRC22M_EN_Msk;
/* Waiting for IRC22M clock ready */
CLK_WaitClockReady(CLK_CLKSTATUS_IRC22M_STB_Msk);
/* Switch HCLK clock source to XTAL */
CLK->CLKSEL0 &= ~CLK_CLKSEL0_HCLK_S_Msk;
CLK->CLKSEL0 |= CLK_CLKSEL0_HCLK_S_Msk;
/* Enable IP clock */
CLK->APBCLK |= CLK_APBCLK_UART_EN_Msk; // UART Clock Enable
/* Select IP clock source */
CLK->CLKSEL1 &= ~CLK_CLKSEL1_UART_S_Msk;
CLK->CLKSEL1 |= CLK_CLKSEL1_UART_S_Msk; // Clock source from external 12 MHz or 32 KHz crystal clock
/* Update System Core Clock */
/* User can use SystemCoreClockUpdate() to calculate PllClock, SystemCoreClock and CycylesPerUs automatically. */
SystemCoreClockUpdate();
/*---------------------------------------------------------------------------------------------------------*/
/* Init I/O Multi-function */
/*---------------------------------------------------------------------------------------------------------*/
/* Set P1 multi-function pins for UART1 RXD and TXD */
SYS->P1_MFP &= ~(SYS_MFP_P12_Msk | SYS_MFP_P13_Msk);
SYS->P1_MFP |= (SYS_MFP_P12_RXD | SYS_MFP_P13_TXD);
/* Lock protected registers */
SYS_LockReg();
}
|