⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.c

📁 DSP实现三相异步电机矢量控制的C语言算法
💻 C
字号:
/**
* @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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -