STM32F103启动代码
时间: 2024-02-05 18:45:57 浏览: 131
stm32F103单片机启动代码bootloader.zip
5星 · 资源好评率100%
以下是STM32F103启动代码的基本框架,你可以根据自己的需求对其进行修改:
```
/* Define the vector table */
__attribute__ ((section(".isr_vector")))
void (* const g_pfnVectors[])(void) =
{
(void (*)(void))((uint32_t)&_estack), /* The initial stack pointer */
Reset_Handler, /* Reset Handler */
NMI_Handler, /* NMI Handler */
HardFault_Handler, /* Hard Fault Handler */
/* ... */
};
/* Reset handler */
void Reset_Handler(void)
{
/* Copy data from flash to RAM */
uint32_t *pSrc, *pDest;
pSrc = &_etext;
pDest = &_sdata;
while(pDest < &_edata)
{
*pDest++ = *pSrc++;
}
/* Initialize the bss segment to zero */
pDest = &_sbss;
while(pDest < &_ebss)
{
*pDest++ = 0;
}
/* Call SystemInit() */
SystemInit();
/* Call main() */
main();
}
/* System initialization */
void SystemInit(void)
{
/* ... */
/* Configure the system clock */
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON);
RCC_WaitForHSEStartUp();
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
RCC_PLLCmd(ENABLE);
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
while(RCC_GetSYSCLKSource() != 0x08);
RCC_HCLKConfig(RCC_SYSCLK_Div1);
RCC_PCLK1Config(RCC_HCLK_Div2);
RCC_PCLK2Config(RCC_HCLK_Div1);
/* ... */
}
/* Application main function */
int main(void)
{
/* ... */
while(1)
{
/* ... */
}
}
```
阅读全文