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

📄 config.h

📁 设计大赛寻迹小车题目程序
💻 H
字号:
#ifndef __config_H__
#define __config_H__ 1

/*********************************************/
#define M8    1
#define M16   2
#define M32   3
#define M64   4
#define M128  5
/*********************************************/
#define CPU_TYPE  M32

//定义MCU时钟频率
//#define F_CPU 14745600
#define F_CPU 7372800
//**************************************************
//包含系统头文件,请根据实际需要进行裁减
//**************************************************
//#pragma REGPARMS
#if CPU_TYPE == M128
#include <iom128v.h>
#endif
#if CPU_TYPE == M64
#include <iom64v.h>
#endif
#if CPU_TYPE == M32
#include <iom32v.h>
#endif
#if CPU_TYPE == M16
#include <iom16v.h>
#endif
#if CPU_TYPE == M8
#include <iom8v.h>
#endif
//#include <intrins.h>
//#include <absacc.h>
#include <string.h>
//#include <FLOAT.H>
//#include <math.h>
//#include <stdlib.h>
#include <macros.h>
//#include <eeprom.h>
//#define const code

//**************************************************
//系统数据类型定义
//**************************************************
#ifndef TRUE
#define TRUE  1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef NULL
#define NULL 0
#endif
#define MIN(a,b)			((a<b)?(a):(b))
#define MAX(a,b)			((a>b)?(a):(b))
#define ABS(x)				((x>0)?(x):(-x))
typedef unsigned char  uint8;                                   /* 定义可移植的无符号8位整数关键字            */
typedef signed   char  int8;                                    /* 定义可移植的有符号8位整数关键字            */
typedef unsigned int   uint16;                                  /* 定义可移植的无符号16位整数关键字           */
typedef signed   int   int16;                                   /* 定义可移植的有符号16位整数关键字           */
typedef unsigned long  uint32;                                  /* 定义可移植的无符号32位整数关键字           */
typedef signed   long  int32;                                   /* 定义可移植的有符号32位整数关键字           */

//**************************************************
//包含工程头文件,请根据需要进行裁减
//**************************************************
#include "unit.h"
//#include "lcddrive.h"
#include "main.h"
#include "motor.h"
//#include "queue.h"
//#include "TWI.h"
//#include "sio.h" 
//**************************************************
//一下为工程变量、端口定义
//**************************************************

/********************************/
/*     "以下为工程配置"         */
/********************************/

#define T0 used
//#define T1 used
#define T2 used
//#define Int0 used
//#define Int1 used

//计数器0比较计数中断允许
#if T0==used
 #define T0_EN TIMSK |= (1<<OCIE0)|(1<<TOIE0)
 #define T0_UEN TIMSK &=~ (1<<OCIE0)|(1<<TOIE0)
 #define T0_start TCCR0 |= (1<<WGM00)|(1<<WGM01)|(1<<COM01)|0x04;
 //0x04 0100B 代表256预分频
 #define T0_stop TCCR0 = 0x00
#endif

//计数器1定时中断允许 //OVERflow
#if T1==used
 #define T1_EN TIMSK |= (1<<TOIE1)|(1<<TOIE1)
 #define T1_UEN TIMSK &=~ (1<<TOIE1)|(1<<TOIE1)
 #define T1_start TCCR1B = 0x02
 #define T1_stop TCCR1B = 0x00
#endif

//定时器2允许,PWM输出
#if T2==used
 #define T2_EN TIMSK |= (1<<OCIE2)|(1<<TOIE2)
 #define T2_UEN TIMSK &=~ (1<<OCIE2)|(1<<TOIE2)
 #define T2_start TCCR2 = (1<<WGM20)|(1<<WGM21)|(1<<COM21)|0x06
 #define T2_stop TCCR2 = 0x00
 //start timer 快速pwm模式,匹配清零,溢出置位 256分频
 //高比低为:(OCR2-0X55)/(0XFF-OCR2)    OX55++++++(0X77)__________OXFF
 //即OCR2越大,输出越大
#endif


//外部中断T0
#if Int0==used
 #define INT0_EN GICR |= (1<<INT0)
 #define INT0_UEN GICR &=~ (1<<INT0)
#endif


//外部中断T1
#if Int1==used
 #define INT1_EN GICR |= (1<<INT1)
 #define INT1_UEN GICR &=~ (1<<INT1)
#endif


#endif


/**********************end****************************************/

⌨️ 快捷键说明

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