init.c

来自「DSP实现三相异步电机矢量控制的C语言算法」· C语言 代码 · 共 46 行

C
46
字号
/**
* @file init.c
*
* Copyright (c) 2004 Atmel.
*
* @brief Ce fichier permet de
*
* This file is included by all source files in order to access to system wide
* configuration.
* @version 1.0 (CVS revision : $Revision: 1.3 $)
* @date $Date: 2005/11/16 17:18:43 $ (created on 06/04/2004)
* @author $Author: raubree $ (created by Emmanuel David)

*****************************************************************************/

#include "config.h"
#include "inavr.h"
//#include "lib_mcu/pll/pll_drv.h"

/**
* @brief ports direction configuration, timer 0 configuration, run the PLL, allow interruptions
*/
void init(void) {
    /*************************************************************************************/
    /*           ports direction configuration                                           */
    /*************************************************************************************/

      DDRB = 0xC3;
      DDRC = 0x89;
      DDRD = 0x01;
      DDRE = 0x02;

    /*************************************************************************************/
    /*     Timer 0 Configuration : generates the sampling fr閝uency                      */
    /*************************************************************************************/
      TCCR0A = (1<<WGM01);   // mode CTC : Clear Timer on Compare
      TCCR0B = (1<<CS02);    // f_quartz = 8 MHz / 256 = 32 kHz
      OCR0A = 0x20;          // one interruption every ms
      TIMSK0 = (1<<OCIE0A);  // allow interruption when timer=compare

      //Start_pll_64_mega();   // start the PLL at 64 MHz
      //Wait_pll_ready();

      SREG|=0x80;            // allow interruptions,
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?