再看一下上面的STM官方惯用的寄存器版本,编译结果为:
469: RCC->CR |= ((uint32_t)RCC_CR_HSEON);
470:
471: /* 等待HSE时钟就绪 */
0x08000D58 4816 LDR r0,[pc,#88] ; @0x08000DB4
0x08000D5A 6800 LDR r0,[r0,#0x00]
0x08000D5C F4403080 ORR r0,r0,#0x10000
0x08000D60 4914 LDR r1,[pc,#80] ; @0x08000DB4
0x08000D62 6008 STR r0,[r1,#0x00]
472: while ((RCC->CR & RCC_CR_HSERDY) == 0)
473: {}
474:
475: /* 使能 PLL */
0x08000D64 BF00 NOP
0x08000D66 4813 LDR r0,[pc,#76] ; @0x08000DB4
0x08000D68 6800 LDR r0,[r0,#0x00]
0x08000D6A F4003000 AND r0,r0,#0x20000
0x08000D6E 2800 CMP r0,#0x00
0x08000D70 D0F9 BEQ 0x08000D66
476: RCC->CR |= RCC_CR_PLLON;
477:
478: /* 等待直到 PLL 就绪 */
0x08000D72 4810 LDR r0,[pc,#64] ; @0x08000DB4
0x08000D74 6800 LDR r0,[r0,#0x00]
0x08000D76 F0407080 ORR r0,r0,#0x1000000
0x08000D7A 490E LDR r1,[pc,#56] ; @0x08000DB4
0x08000D7C 6008 STR r0,[r1,#0x00]
479: while((RCC->CR & RCC_CR_PLLRDY) == 0)
480: {}
481:
482: /* 把 PLL 作为系统时钟源 */
0x08000D7E BF00 NOP
0x08000D80 480C LDR r0,[pc,#48] ; @0x08000DB4
0x08000D82 6800 LDR r0,[r0,#0x00]
0x08000D84 F0007000 AND r0,r0,#0x2000000
0x08000D88 2800 CMP r0,#0x00
0x08000D8A D0F9 BEQ 0x08000D80
483: RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); //系统时钟选择位(BIT1:0)复位(00为HSI 01为HSE 10为PLL)
0x08000D8C 4809 LDR r0,[pc,#36] ; @0x08000DB4
0x08000D8E 6840 LDR r0,[r0,#0x04]
0x08000D90 F0200003 BIC r0,r0,#0x03
0x08000D94 4907 LDR r1,[pc,#28] ; @0x08000DB4
0x08000D96 6048 STR r0,[r1,#0x04]
484: RCC->CFGR |= (uint32_t)RCC_CFGR_SW_PLL; //系统时钟选择PLL(BIT1位)置1
485:
486: /* 等待,直到 PLL 被用作系统时钟源 */
0x08000D98 4608 MOV r0,r1
0x08000D9A 6840 LDR r0,[r0,#0x04]
0x08000D9C F0400002 ORR r0,r0,#0x02
0x08000DA0 6048 STR r0,[r1,#0x04]
487: while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08) //BIT3为1指示PLL已为钟源
488: {}
0x08000DA2 BF00 NOP
0x08000DA4 4803 LDR r0,[pc,#12] ; @0x08000DB4
0x08000DA6 6840 LDR r0,[r0,#0x04]
0x08000DA8 F000000C AND r0,r0,#0x0C
0x08000DAC 2808 CMP r0,#0x08
0x08000DAE D1F9 BNE 0x08000DA4
489: } |