DC Motor.rar

  • AMP
    了解作者
  • C/C++
    开发工具
  • 55KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 2
    下载次数
  • 2017-11-22 18:48
    上传日期
EMBEDDED C PROGRAM TO INTERFACE DC MOTOR WITH ARM7
DC Motor.rar
  • DC Motor
  • main.c
    1.4KB
  • Dc Motor.uvproj
    14.3KB
  • Dc Motor.uvgui_MicroEmbedded.bak
    133.1KB
  • Dc Motor.lnp
    255B
  • main.crf
    8.9KB
  • Dc Motor.uvgui.MicroEmbedded
    133.1KB
  • Dc Motor.uvopt
    8.1KB
  • Dc Motor_Target 1.dep
    528B
  • Dc Motor.htm
    19.5KB
  • Dc Motor.hex
    5KB
  • Dc Motor.sct
    479B
  • Dc Motor_uvopt.bak
    8.1KB
  • main.d
    59B
  • Dc Motor.tra
    905B
  • Dc Motor.axf
    14.4KB
  • Startup.o
    3.1KB
  • main.o
    24.1KB
  • Dc Motor.plg
    174B
  • Startup.s
    14.5KB
  • Dc Motor.map
    50.4KB
  • Dc Motor_uvproj.bak
    0B
  • Startup.lst
    43.5KB
  • Startup.d
    22B
内容介绍
/* ** DC motor interfaced at CN7 ** P0.6 -> GPIO ** P0.7 -> PWM2 */ #include <lpc214x.h> #define CLOCKWISE 1 #define ANTICLOCKWISE 2 unsigned int period; void PWM_init(void) { period = 10000; PINSEL0 &= 0xFFFF0FFF; /* P0.6 as GPIO */ PINSEL0 |= 0x00008000; /* P0.7 as PWM2 */ IODIR0 |= 0x00000040; /* P0.6 as output */ IOCLR0 = 0x00000040; /* P0.6 = 1 */ PWMPR = 0x16; PWMMCR = 0x00000002; PWMPCR = 0x00000400; PWMMR0 = period; PWMMR2 = period/2; PWMLER = 0x05; PWMTCR = 0x00000009; /* Enable PWM and TC */ } void PWM_SetDutyCycle(unsigned char dir, unsigned int dc) { switch(dir) { case CLOCKWISE: IOCLR0 = 0x00000040; PWMMR2 = (period/100)*dc; PWMLER = 0x05; break; case ANTICLOCKWISE: IOSET0 = 0x00000040; PWMMR2 = period - (period/100)*dc; PWMLER = 0x05; break; } } void delay(unsigned int time) { unsigned int i,j; for(i=0;i<time;i++) for(j=0;j<5000;j++); } int main() { unsigned int i; PWM_init(); while(1) { for(i=0;i<=100;i++) { PWM_SetDutyCycle(CLOCKWISE,i); delay(100); } for(i=100;i>0;i--) { PWM_SetDutyCycle(CLOCKWISE,i); delay(100); } for(i=0;i<=100;i++) { PWM_SetDutyCycle(ANTICLOCKWISE,i); delay(100); } for(i=100;i>0;i--) { PWM_SetDutyCycle(ANTICLOCKWISE,i); delay(100); } } }
评论
    相关推荐