📄 sys.c
字号:
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#include "SYS.h"
/***************variables define ************************/
unsigned char AD[9]; //AD结果值
unsigned char rudder, speed,stop,i,buf;
//rudder 为送舵机控制量值,speed为送速度控制量值,
//stop为送刹车控制量值,
//i为循环变量,buf 为 PB的缓冲值,count为计时器溢出次数。
char lastposition,position,positionbuf,pola;
//lastposition 为上个循环的位置值,
//position为位置值,positionbuf为位置的暂存值,pola为位置的极性
unsigned int time,count,lasttime,thistime;
//time为小轮一圈的时间1表示0.0013653s 一圈4cm
//timeset为time的设定值,timebuf为time的暂存值
/************************subroutine define****************/
#pragma CODE_SEG DEFAULT
void SYS_Init()
{
rudder=RUDDERDEFAULT;
speed=SPEEDDEFAULT;
stop=STOPDEFAULT;
pola=1;
position=0;
positionbuf=0;
count=0;
lasttime=0;
thistime=0;
DDRA=0x0;
DDRB=0xff;
DDRH=0x00;
CLK_Init();
ECT_Init();
PWM_Init();
AD_Init();
}
void CLK_Init()
{
CLKSEL_PLLSEL = 0x0;
REFDV = REFDV_VALUE; // 选择分频以及倍频系数
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -