/* MAXMC11A echos command characters to terminal */ /* ROM version */ /* MAX MC11 TEST PROGRAM */ /* by AJ Neal */ /* includes sonar code */ /* includes encoder code */ /* Copyright 2000 - Zagros Robotics, All Rights Reserved */ /* set up for 32k eeprom */ #data 0x0000 /* Data segment is at $0000 */ #code 0x8000 /* Code segment is at $E000 */ #stack 0xFF /* Base Address of Stack is $100 */ #include #include <68hc11.h> #include #include #include #include /* Link in the following libraries (nearly all needed by fprintf() )*/ #include #include #include #include #include #include #include #include #include #include /* main vars */ char c; /* Declare char variable c */ FILE stdout; /* sonar vars */ unsigned int sonar_range; unsigned int sonar_init; /* advance , encoder vars */ int m1count; int m1temp; int m1old; ping(unit) int unit; { int sonar_temp; int sonar_old; pokeb(REG_BASE+PORTD,4); /* PING SONAR UNIT 1*/ sonar_init=peek(REG_BASE+TCNT); sonar_range=0; do { sonar_range=peek(REG_BASE+TCNT); sonar_range=sonar_range-sonar_init; sonar_temp=peekb(REG_BASE+PORTA); }while(((sonar_temp&1)==0)||(sonar_range<6000)); pokeb(REG_BASE+PORTD,0); return(sonar_range); }/* end ping function */ advance(distance) int distance; { m1count=0; while(m1count