|
最近在玩这块板子,时钟方面参考了版主的程序。SystemInit之后,配置GCLK1时钟给I2S用,发现系统时钟就从48M回到了8M,百思不得其解。后来仔细看了看GCLK的说明,在系统时钟初始化之前,将APB中的GCLK电源使能,然后程序就正常了,以下是修改后的SystemInit代码,如果理解有错误请大神们指出~- PM->APBAMASK.reg |= 0x1<<3; //开启GCLK供电
- SYSCTRL->OSC8M.bit.PRESC = 0; //OSC8M不分频
- REG_SYSCTRL_DFLLCTRL = 1<<1; //使能DFLL
- SYSCTRL->DFLLVAL.bit.COARSE = *(uint32_t*)(NVMCTRL_OTP4 + 4) >> 26; //将校准值写入相应寄存器
- SYSCTRL->DFLLVAL.bit.FINE = *(uint32_t*)(NVMCTRL_OTP4 + 8) & 0x3ff;
- while(!(REG_SYSCTRL_PCLKSR&(0x1<<4)) ); //等待时钟同步完成
- NVMCTRL->CTRLB.bit.RWS = NVMCTRL_CTRLB_RWS_HALF_Val; //等待时钟设为1?
- REG_GCLK_GENCTRL = (GCLK_SOURCE_DFLL48M<<8) | (0x1<<16) | (1<<17); //时钟源选择DFLL | 时钟发生器使能
复制代码
|
|