?? 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 + -