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

📄 hardwareoperation.c

📁 智能车控制
💻 C
字号:
#include <hidef.h>      /* common defines and macros */
#include <mc9s12dg128.h>     /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"

#define uch unsigned char

/*  These are used for other programs
extern void set_motor(uch,uch);
extern void set_DJ(unsigned short);
extern uch AD0_convert(uch);
extern uch AD1_convert(uch);
*/

// set motor speed
void set_motor(unsigned short fward,unsigned short bward) {
  PWMDTY23=fward;
  PWMDTY45=bward;
}

// set the direction
void set_DJ(unsigned short DJ) {
  PWMDTY01=DJ;
}

//ATD0
uch AD0_convert(uch ch){
  uch *p;
  ATD0CTL2=0xC0;
  ATD0CTL5=0x80+ch;
  while(ATD0STAT1==0);
  p=&ATD0DR0L;
  ATD0CTL2=0x40;
  return(*p);
}
  
uch AD1_convert(uch ch){
  uch *p;
  ATD1CTL2=0xC0;
  ATD1CTL5=0x80+ch;
  while(ATD1STAT1==0);
  p=&ATD1DR0L;
  ATD1CTL2=0x40;
  return(*p);
}  

⌨️ 快捷键说明

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