zoukankan      html  css  js  c++  java
  • EFM32之CMU

    此程序是配置EFM32的时钟频率,用OUTPUT_INTERNAL和OUTPUT_EXTERNAL来区分是内部时钟和外部时钟。    

    通过用示波器测量PA1脚和PA2脚的频率,证明程序完全正确。

    #include <stdint.h>
    #include <stdbool.h>
    #include "efm32.h"
    #include "efm32_chip.h"
    #include "efm32_cmu.h"
    #include "efm32_gpio.h"
    
    #define OUTPUT_INTERNAL      1      //GPIO输出内部振荡波形
    //#define OUTPUT_EXTERNAL      2    //GPIO输出外部晶振波形
    
    int main(void)
    {
      /* Chip errata */
      CHIP_Init();
    
    #ifdef OUTPUT_INTERNAL
      CMU_HFRCOBandSet(cmuHFRCOBand_1MHz);
      CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);//1MHz
      CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFRCO);//32KHz
    #elif defined OUTPUT_EXTERNAL
      CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFXO);//32MHz
      CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFXO);//32KHz
    #endif
    
      CMU_ClockEnable(cmuClock_GPIO,true);  //使能GPIO模块
      GPIO_PinModeSet(gpioPortA, 1, gpioModePushPull, 1);  //将相应的GPIO口设置成输出,低频
      GPIO_PinModeSet(gpioPortA, 2, gpioModePushPull, 1);  //将相应的GPIO口设置成输出,高频
      
    #ifdef OUTPUT_INTERNAL
      CMU->CTRL |= CMU_CTRL_CLKOUTSEL0_HFRCO + CMU_CTRL_CLKOUTSEL1_LFRCO;//CMU_CTRL_CLKOUTSEL0_HFXO; //配置为HFRCO输出
    #elif defined OUTPUT_EXTERNAL
      CMU->CTRL |= CMU_CTRL_CLKOUTSEL0_HFXO + CMU_CTRL_CLKOUTSEL1_LFXO;
    #endif
      
    
      //允许GPIO的复用功能,并且置位允许位
      CMU->ROUTE = CMU_ROUTE_CLKOUT0PEN | CMU_ROUTE_CLKOUT1PEN | CMU_ROUTE_LOCATION_LOC0;      
    
    
      while (1)
      {
          
      }
    }
  • 相关阅读:
    python
    spice-vdagent
    no ia32-libs
    git conflict
    wget mirror
    docker !veth
    libprotobuff8.so not found
    angular 列表渲染机制
    Java测试技巧
    react组件生命周期
  • 原文地址:https://www.cnblogs.com/zpehome/p/2981204.html
Copyright © 2011-2022 走看看