RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; //HSE表示使用外部时钟,HSI表示使用的是内部时钟
RCC_OscInitStruct.HSEState = RCC_HSE_ON; // 打开外部时钟
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; //时钟源设置
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6; //表示6倍频率,如果外部时钟源是8MHZ,那么6倍的倍频就是48MHZ
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1; // 对时钟源的分频 如果是48MHZ,,2分频就是24MHZ
HAL_RCC_OscConfig(&RCC_OscInitStruct);
#define RCC_OSCILLATORTYPE_NONE ((uint32_t)0x00000000)
#define RCC_OSCILLATORTYPE_HSE ((uint32_t)0x00000001)
#define RCC_OSCILLATORTYPE_HSI ((uint32_t)0x00000002)
#define RCC_OSCILLATORTYPE_LSE ((uint32_t)0x00000004) //低频外部时钟
#define RCC_OSCILLATORTYPE_LSI ((uint32_t)0x00000008)//低频内部时钟
#define RCC_OSCILLATORTYPE_HSI14 ((uint32_t)0x00000010)
低频时钟只是用于RTC,RTC主要用来做低功耗
void IAP_Set(void)
{
uint32_t i = 0;
/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
/* Copy the vector table from the Flash (mapped at the base of the application
load address 0x08003000) to the base address of the SRAM at 0x20000000. */
for(i = 0; i < 48; i++)
{
*((uint32_t*)(0x20000000 + (i << 2)))=*(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2));
}
/* Enable the SYSCFG peripheral clock*/
RCC->APB2ENR |= RCC_APB2ENR_SYSCFGCOMPEN;
/* Remap SRAM at 0x00000000 */
Memory_Remap(SYSCFG_MemoryRemap_SRAM);
}
#define APPLICATION_ADDRESS ((uint32_t)0x08004000) 函数运行的地址,有boot的时候函数是从自己设置的地址开始运行的
『本文转载自网络,版权归原作者所有,如有侵权请联系删除』