#include <16F648a.h>
#fuses NOLVP,NOMCLR,INTRC,NOPROTECT,NOCPD
#use delay(clock=4000000)
static int const LookUpTableMotor1[8]={0x01,0x09,0x08,0x0c,0x04,0x06,0x02,0x03}; //Define a look up table for motor 1
static int const LookUpTableMotor2[8]={0x01,0x09,0x08,0x0c,0x04,0x06,0x02,0x03}; //Define a look up table for motor 2
{
struct Motor_pin_Definition // Define a memory structure to overlay the IO Ports
int sensor: 4;
Boolean light1;
Boolean light2;
int unuesed: 2;
int motor1: 4;
int motor2: 4;
}MotorPort, MotorPortDirection; //Make two copies of this structure
#Byte MotorPort=0x05 //Lock these copies down to a particular location
#Byte MotorPortDirection=0x85
#define Forever 1 //define forever 1
#define speed 20
#define slowspeed 500
int counter1=0;
int counter2=0;
int speed1;
int speed2;
int TableIndex1=0;
int TableIndex2=0;
#int_RTCC //interrupt function
void Timer0_isr() // if counter1 overflows speed1 the motor one will rotate once
{ //if counter2 overflows speed2 the motor two will rotate once
counter1++;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余4页未读,立即下载