载入中...   AVR  ZONE
 
致力于工业自动化控制、电子产品开发、单片机应用开发
 
这么多年了,我一直坚持走技术这条路,走自己喜欢的这条路,希望无悔......

他们彼此深信,是瞬间迸发的热情让他们相遇。这样的确定是美丽的...
 
 
 最新更新
这几年就这样走过来了,时间过得好快,发生太多事情,我希望我的选择是正确的。
有人说,男人把自己的热爱当成自己的事业是一种失败。但我希望,我会成功!
坚持不放弃!
2007-12-27 21:53:00
STM32F10xx时钟系统框图
STM32 发表于 2007-12-26 22:46 ST MCU ←返回版面 按此察看该网友的资料 按此把文章加入收藏夹 按此编辑本帖

楼主: STM32F10xx时钟系统框图:时钟是整个系统的脉搏

下图是STM32F10xx时钟系统的框图,通过这个图可以一目了然地看到各个部件时钟产生的路径,还可以很方便地计算出各部分的时钟频率。

STM32的四个时钟源(HSI、HSE、LSI和LSE)也在图中标出;图中间的时钟监视系统(CSS)是在很多ST7的单片机中就出现的安全设置。

图的右边,输出定时器时钟之前有一个乘法器,它的操作不是由程序控制的,是由硬件根据前一级的APB预分频器的输出自动选择,当APB预分频器的分频因子为1时,这个乘法器无作用;当APB预分频器的分频因子大于1时,这个乘法器做倍频操作,即将APB预分频器输出的频率乘2,这样可以保证定时器可以得到最高的72MHz时钟脉冲。



 
 
grant_jx 发表于 2007-12-26 23:45 ST MCU ←返回版面 按此察看该网友的资料 按此把文章加入收藏夹 按此编辑本帖

3楼: 我也偷偷懒吧,如下例子

记得启动CSS前要:
  /* Enable Clock Security System(CSS) */
  RCC_ClockSecuritySystemCmd(ENABLE);



代码放到RCC_IRQHandler中断中,

/* This interrupt is generated when HSE clock fails */
  if (RCC_GetITStatus(RCC_IT_CSS) != RESET)
  {
    /* At this stage: HSE, PLL are disabled (but no change on PLL config) and HSI is selected as system clock source */

    /* Enable HSE */
    RCC_HSEConfig(RCC_HSE_ON);

    /* Enable HSE Ready interrupt */
    RCC_ITConfig(RCC_IT_HSERDY, ENABLE);

    /* Enable PLL Ready interrupt */
    RCC_ITConfig(RCC_IT_PLLRDY, ENABLE);

    /* Clear Clock Security System interrupt pending bit */
    RCC_ClearITPendingBit(RCC_IT_CSS);

    /* Once HSE clock recover, the HSERDY interrupt is generated and in the RCC ISR routine the system clock will be reconfigured to its previous state (before HSE clock failure) */
  }


hotpower在另外的帖子里问得需要指示,可以通过这个函数RCC_GetITStatus(RCC_IT_CSS)得到。上面的中断服务程序作用在最后的说明有解释。
 
 
香水城 发表于 2007-12-27 10:40 ST MCU ←返回版面 按此察看该网友的资料 按此把文章加入收藏夹 按此编辑本帖

4楼: STM32当然有“检测外振停振自动切换为RC功能”,不但如此......

首先,把《STM32技术参考手册》中有关部分抄录如下:

4.2.7  时钟安全系统(CSS)
  时钟安全系统可以通过软件被激活。一旦其被激活,时钟监测器将在HSE振荡器启动延迟后被使能,并在HSE时钟关闭后关闭。

  如果HSE时钟发生故障,此振荡器自动地被关闭,时钟失效事件将被送到高级定时器TIM1的刹车输入端,并产生时钟安全中断CSSI,允许软件完成营救操作。此CSSI中断被连接到Cortex-M3 NMI的中断。

注意:一旦CSS被激活,并且HSE时钟出现故障,就产生CSS中断,并且也自动产生NMI。NMI将被不断执行,直到CSS中断挂起位被清除。因此,在NMI的处理程序中必须通过设置时钟中断寄存器(RCC_CIR)里的CSSC位来清除CSS中断。

如果HSE振荡器被直接或间接地作为系统时钟来用的话,(间接的意思是:它被作为PLL输入时钟,并且PLL时钟被作为系统时钟),时钟故障将导致系统时钟自动切换到HSI振荡器,同时外部HSE振荡器被关闭。在时钟失效时,如果HSE振荡器时钟(被分频或未被分频)是用作系统时钟的PLL的输入时钟,PLL也将被关闭。

以下是英文原文供对照
Clock Security System can be activated by software. In this case, the clock detector is enabled after the HSE oscillator startup delay, and disabled when this oscillator is stopped.

If a failure is detected on the HSE oscillator clock, this oscillator is automatically disabled, a clock failure event is sent to the break input of the TIM1 Advanced control timer and an interrupt is generated to inform the software about the failure (Clock Security System Interrupt CSSI), allowing the MCU to perform rescue operations. The CSSI is linked to the Cortex™-M3 NMI (Non-Maskable Interrupt) exception vector.

Note: Once the CSS is enabled and if the HSE clock fails, the CSS interrupt occurs and an NMI is automatically generated. The NMI will be executed indefinitely unless the CSS interrupt pending bit is cleared. As a consequence, in the NMI ISR user must clear the CSS interrupt by setting the CSSC bit in the Clock interrupt register (RCC_CIR).

If the HSE oscillator is used directly or indirectly as the system clock (indirectly means: it is used as PLL input clock, and the PLL clock is used as system clock), a detected failure causes a switch of the system clock to the HSI oscillator and the disabling of the external HSE oscillator. If the HSE oscillator clock (divided or not) is the clock entry of the PLL used as system clock when the failure occurs, the PLL is disabled too.


LZ的图中间橙黄色标有CSS的方块就是代表这个“时钟安全系统”,它控制位于图中上方的多路开关,一旦HSE、PLL或外部晶体出现故障,CSS会自动地把多路开关拨向HSI一侧,这样SYSCLK将由内部RC振荡器驱动。

当CSS检测到HSE、PLL或外部晶体出现故障时,会通过NMI产生一个中断,使软件能够及时介入处理这个紧急事件。

因为STM32F103带有电机控制的高级定时器TIM1,当上述紧急事件发生时,CSS还要向TIM1发出刹车信号。软件可以利用这个机制有效地保护外围的控制电路。
 
 
 
posted @ 2007-12-27 21:53:00 AVR猎手 阅读全文 | 回复(0) | 引用通告 | 编辑
  • 标签:STM32 
  • 发表评论:
    载入中...
    载入中...
     
     

    公告

    • 载入中...

    产品中心

    卷布机(布料、薄膜等)对边控制器
     

    原创

        基于ATmega48的串口电压表的制作
     

    推荐版块

        首页
        AVR单片机专栏   
        单片机技术
        LCD液晶应用(AVR)
        项目方案
        PCB技术(Altium designer 6)
        FPGA技术(Altium designer 6)
        心情日记
        放松一下
        侦探悬疑推理故事
        手工漫画作品
     

    版块文章分类

     

    友情链接

    最新评论

    最新日志

    留言簿

    搜索

    登陆

    21IC官方统计