打印
[STM32F4]

STM32F407时钟设置

[复制链接]
1101|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
feiyang0725|  楼主 | 2017-10-10 17:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
同样的定时器程序NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);/
        delay_init(168);  //
        LED_Init();                                //

        TIM3_Int_Init(5000-1,8400-1);        
        while(1)
        {
                LED0=!LED0;//DS0·-×a
                delay_ms(200);//
        };
我用例子里面的代码,定时500ms,刷写到原子的板子是500ms,刷写到我的板子变2s,隔了4倍。。晶振都是一样的。。这是为什么?

沙发
mmuuss586| | 2017-10-10 18:14 | 只看该作者
把系统时钟读出来,测试下,现在的时钟倍频到多少

使用特权

评论回复
板凳
feiyang0725|  楼主 | 2017-10-10 18:25 | 只看该作者
mmuuss586 发表于 2017-10-10 18:14
把系统时钟读出来,测试下,现在的时钟倍频到多少

一样的程序一样的设置,时钟也都是8M的。。。

使用特权

评论回复
地板
feiyang0725|  楼主 | 2017-10-10 18:26 | 只看该作者
只是两块PCB不同。。。

使用特权

评论回复
5
feiyang0725|  楼主 | 2017-10-10 18:28 | 只看该作者
void delay_init(u8 SYSCLK)
{
#if SYSTEM_SUPPORT_OS                                                 //Èç¹ûÐèÒªÖ§³ÖOS.
        u32 reload;
#endif
        SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
        fac_us=SYSCLK/8;                                                //²»ÂÛÊÇ·ñʹÓÃOS,fac_us¶¼ÐèҪʹÓÃ
#if SYSTEM_SUPPORT_OS                                                 //Èç¹ûÐèÒªÖ§³ÖOS.
        reload=SYSCLK/8;                                                //ÿÃëÖӵļÆÊý´ÎÊý µ¥Î»ÎªM          
        reload*=1000000/delay_ostickspersec;        //¸ù¾Ýdelay_ostickspersecÉ趨Òç³öʱ¼ä
                                                                                        //reloadΪ24λ¼Ä´æÆ÷,×î´óÖµ:16777216,ÔÚ168MÏÂ,Ô¼ºÏ0.7989s×óÓÒ       
        fac_ms=1000/delay_ostickspersec;                //´ú±íOS¿ÉÒÔÑÓʱµÄ×îÉÙµ¥Î»          
        SysTick->CTRL|=SysTick_CTRL_TICKINT_Msk;           //¿ªÆôSYSTICKÖжÏ
        SysTick->LOAD=reload;                                         //ÿ1/delay_ostickspersecÃëÖжÏÒ»´Î       
        SysTick->CTRL|=SysTick_CTRL_ENABLE_Msk;         //¿ªÆôSYSTICK   
#else
        fac_ms=(u16)fac_us*1000;                                //·ÇOSÏÂ,´ú±íÿ¸ömsÐèÒªµÄsystickʱÖÓÊý   
#endif
}                                                                  

使用特权

评论回复
6
feiyang0725|  楼主 | 2017-10-10 18:29 | 只看该作者
void SystemInit(void)
{
  /* FPU settings ------------------------------------------------------------*/
  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
    SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */
  #endif
  /* Reset the RCC clock configuration to the default reset state ------------*/
  /* Set HSION bit */
  RCC->CR |= (uint32_t)0x00000001;

  /* Reset CFGR register */
  RCC->CFGR = 0x00000000;

  /* Reset HSEON, CSSON and PLLON bits */
  RCC->CR &= (uint32_t)0xFEF6FFFF;

  /* Reset PLLCFGR register */
  RCC->PLLCFGR = 0x24003010;

  /* Reset HSEBYP bit */
  RCC->CR &= (uint32_t)0xFFFBFFFF;

  /* Disable all interrupts */
  RCC->CIR = 0x00000000;

#if defined (DATA_IN_ExtSRAM) || defined (DATA_IN_ExtSDRAM)
  SystemInit_ExtMemCtl();
#endif /* DATA_IN_ExtSRAM || DATA_IN_ExtSDRAM */
         
  /* Configure the System clock source, PLL Multiplier and Divider factors,
     AHB/APBx prescalers and Flash settings ----------------------------------*/
  SetSysClock();

  /* Configure the Vector Table location add offset address ------------------*/
#ifdef VECT_TAB_SRAM
  SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
  SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

31

主题

124

帖子

1

粉丝