一、记录以下代码
准备电子设计大赛,浅浅的学习了MSP432的时钟设置模块,记录如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#include "normal.h"
void systick_delay(uint32 t) { SysTick-> CTRL = 0x00; SysTick->LOAD = t - 1; SysTick->VAL = 0x00; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; while( !(SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)); }
void systick_delay_ms (uint32 time) { while(time--) systick_delay(SystemCoreClock / 1000); }
SysClockStructure SysClock;
void Clock_ReConfig(void) { GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ,GPIO_PIN3 | GPIO_PIN2, GPIO_PRIMARY_MODULE_FUNCTION); CS_setExternalClockSourceFrequency(32000,48000000); PCM_setCoreVoltageLevel(PCM_VCORE1); FlashCtl_setWaitState(FLASH_BANK0, 1); FlashCtl_setWaitState(FLASH_BANK1, 1); CS_startHFXT(false);
CS_initClockSignal(CS_MCLK , CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1); CS_initClockSignal(CS_ACLK , CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1); CS_initClockSignal(CS_HSMCLK, CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1); CS_initClockSignal(CS_SMCLK , CS_HFXTCLK_SELECT, CS_CLOCK_DIVIDER_1); CS_initClockSignal(CS_BCLK , CS_REFOCLK_SELECT, CS_CLOCK_DIVIDER_1); SysClock.aclk = CS_getACLK(); SysClock.mclk = CS_getMCLK(); SysClock.smclk = CS_getSMCLK(); SysClock.hsmclk = CS_getHSMCLK(); SysClock.bclk = CS_getBCLK(); FPU_enableModule(); FPU_enableLazyStacking(); }
|