/* filename ******* Motor.C ******************* demonstration of the DC motor, incremental control This example accompanies the book "Embedded Microcomputer Systems: Real Time Interfacing", Brooks-Cole, copyright (c) 2000, Jonathan W. Valvano 5/4/99 Interface between the TExaS simulator running a MC68HC11 EVB with ICC11 freeware compiler TExaS Copyright 1999 by Jonathan W. Valvano for more information about ICC11 see http://www.imagecraft.com You may use this file without restrictions PortB connected to 8-bit D/A delivers power to motor PE2 8 bit A/D reads speed from tachometer */ #include "HC11.h" unsigned char power,speed; #define SetPoint 128 void main(void){ power=0; OPTION=0x80; /* turn on A/D power */ while(1){ PORTB=power; /* output to actuator */ ADCTL=2; /* 4 conversions on channel 2 */ while((ADCTL&0x80)==0){}; speed=ADR1; if(speed1) power--; } } } void resetVectors(void){ /* not really a function, but this must be last */ asm(" org $FFFE"); asm(" FDB __start"); asm(" org $FC00"); /* puts rts in a harmless place */ /* string constants also placed here */ /* the value FC00 means you can have up to 1000 characters of strings */ }