<html><head><title></title><!-- <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> --> <link rel="stylesheet" href="programCode_fichiers/style.css"> <script language="javascript" src="programCode_fichiers/js.js"></script></head> <body bgcolor="#f0f0f0"> <table style="border-collapse: collapse;" border="1" bordercolor="#000000" cellpadding="6" cellspacing="0" width="100%"><tbody><tr><td background="programCode_fichiers/title_gradient_large_red.gif" bgcolor="#800000"><font class="largeframe"><nobr>Program Code</nobr><nobr></nobr></font></td></tr> <tr><td bgcolor="#ffffff"> <a href="http://www.it.lth.se/digp/sammanfattning/2001/lp-2/grupp16/techReport.html">Back</a> <br><br><br> <h2>main.c</h2><br> <br>//Yee Yik &amp; Andreas Lundgren <br>//Digital Project Fall 2001 <br>//Group 16 <br> <br>//Main program <br>&nbsp; <br>#include "IO-reg.h" <br>#include "checkNumPad.h" <br>#include "LCD_driver.h" <br>#include "buttonHandler.h" <br>#include "measureMode.h" <br> <br>char writePosition; <br>unsigned int adjustmentNumber; <br>unsigned long measuredTime; <br>unsigned int nbrOverflow; <br>unsigned int deltaF; <br> <br>void main (void) { <br> <br>&nbsp; &nbsp; char button; <br>&nbsp; &nbsp; unsigned int temp_nbrOf;&nbsp; //temparary store # of overflow so we can restore the original value later <br>&nbsp; <br>&nbsp; &nbsp; /*Initialise the LCD*/ <br>&nbsp; &nbsp; initLCD(); <br>&nbsp; &nbsp; //set position to kolumn 1, row 2. <br>&nbsp; &nbsp; writePosition = 0x40; <br> <br>&nbsp; &nbsp; //set PORTA, bit 3, as input <br>&nbsp; &nbsp; PACTL &amp;= 0xF7; <br> <br>&nbsp; &nbsp; //Turn flash trigger off. <br>&nbsp; &nbsp; PORTD &amp;= 0xEF;&nbsp; &nbsp; <br> <br>&nbsp; &nbsp; //set PORTD, bit 4, as output, rest as input <br>&nbsp; &nbsp; DDRD |= 0x10; <br>&nbsp; &nbsp; DDRD &amp;= 0xD0; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; measuredTime = 0; <br>&nbsp; &nbsp; adjustmentNumber = 0; <br>&nbsp; &nbsp; nbrOverflow = 0; <br>&nbsp; &nbsp; deltaF = 0; <br> <br>&nbsp; &nbsp; while (1){ <br>&nbsp; &nbsp; /*Check if a buton is pressed, and use the result to display on LCD right away <br>&nbsp; &nbsp; &nbsp; then wait for the bouncing of 0&amp;1 result from button pressing to stop, <br>&nbsp; &nbsp; &nbsp; wait for button is released, <br>&nbsp; &nbsp; &nbsp; and wait for the bouncing result from releasing button to stop*/ <br> <br>&nbsp; &nbsp; if ((PORTA &amp; 8) != 0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; PORTB &amp;= 0xF7; //Turn light diode off; <br>&nbsp; &nbsp; &nbsp; &nbsp; if ((PORTA &amp; 4) != 0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startMeasure(); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredTime = nbrOverflow; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredTime = measuredTime * 0xFFFF; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredTime = measuredTime + deltaF; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_long_position(0, measuredTime); <br>&nbsp; &nbsp; &nbsp; &nbsp; } else { <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp_nbrOf = nbrOverflow; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startShooting(); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nbrOverflow = temp_nbrOf; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; while ((PORTA &amp; 8) != 0){} // Waiting for button to be released <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; PORTB |= 0x08; //Turn light diode on; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; button = checkNumPad();&nbsp; <br>&nbsp; &nbsp; if ((button) &gt; 0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; button_handler(button); <br>&nbsp; &nbsp; &nbsp; &nbsp; wait_bouncing(); <br>&nbsp; &nbsp; &nbsp; &nbsp; wait_button_release(); <br>&nbsp; &nbsp; &nbsp; &nbsp; wait_bouncing(); <br>&nbsp; &nbsp; }&nbsp; //end of if (button is pressed)&nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; } //end of while loop <br>} <br> <br> <br><h2>buttonHandler.h</h2><br> <br>void button_handler(char button); <br>char *long_to_string(long number); <br> <br> <br><h2>buttonHandler.c</h2><br> <br>//Yee Yik &amp; Andreas Lundgren <br>//Digital Project Fall 2001 <br>//Group 16 <br> <br>/*Button handler program <br>&nbsp; Get a button 1-16 and handles it.*/ <br>&nbsp; <br>#include "LCD_driver.h" <br> <br>extern char writePosition; <br>extern int adjustmentNumber; <br>extern long measuredTime; <br>extern unsigned int nbrOverflow; <br>extern unsigned int deltaF; <br> <br> <br>char *long_to_string(long number) <br>{ <br>&nbsp; char string[11]; <br>&nbsp; short pos2 = 9; <br>&nbsp; <br>&nbsp; while (number &gt; 0) <br>&nbsp; { <br>&nbsp; &nbsp; &nbsp; string[pos2] = (number % 10) + '0'; <br>&nbsp; &nbsp; &nbsp; number = number / 10; <br>&nbsp; &nbsp; &nbsp; pos2--; <br>&nbsp; } <br>&nbsp; string[10] = 0; <br>&nbsp; return &amp;string[++pos2]; <br>} <br> <br>//char button_handler(char button, char writePosition) <br>void button_handler(char button) <br>{ <br>&nbsp; switch (button) <br>&nbsp; { <br>&nbsp; &nbsp; &nbsp; case 1: <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 2: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 7; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'7'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 3: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 4; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'4'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 4: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 1; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'1'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 5: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'0'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 6: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 8; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'8'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 7: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 5; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'5'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 8: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 2; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'2'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 9: <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 10: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 9; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'9'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 11: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 6; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'6'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 12: <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &lt; 0x44){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber * 10) + 3; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(writePosition,'3'); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition++; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 13: //a backspace button <br>&nbsp; &nbsp; &nbsp; &nbsp; if (writePosition &gt; 0x40){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_character_position(--writePosition, 20);&nbsp; //write a space to the position <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = (adjustmentNumber / 10); <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 14: <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 15:&nbsp; //minus sign <br>&nbsp; &nbsp; &nbsp; &nbsp; if ((measuredTime - adjustmentNumber) &gt; 0){ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clear_display(); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; measuredTime = measuredTime - adjustmentNumber; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (deltaF &lt; adjustmentNumber) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nbrOverflow--; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; deltaF = deltaF - adjustmentNumber; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; write_long_position(0x0,measuredTime); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writePosition = 0x40; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; } <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; &nbsp; &nbsp; case 16:&nbsp; //plus sign <br>&nbsp; &nbsp; &nbsp; &nbsp; clear_display(); <br>&nbsp; &nbsp; &nbsp; &nbsp; measuredTime = measuredTime + adjustmentNumber; <br>&nbsp; &nbsp; &nbsp; &nbsp; deltaF = deltaF + adjustmentNumber; <br>&nbsp; &nbsp; &nbsp; &nbsp; if (deltaF &lt; adjustmentNumber)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nbrOverflow++; <br>&nbsp; &nbsp; &nbsp; &nbsp; write_long_position(0x0,measuredTime); <br>&nbsp; &nbsp; &nbsp; &nbsp; writePosition = 0x40; <br>&nbsp; &nbsp; &nbsp; &nbsp; adjustmentNumber = 0; <br>&nbsp; &nbsp; &nbsp; &nbsp; break; <br>&nbsp; } <br>&nbsp; <br>} <br> <br> <br><h2>checkNumPad.h</h2><br> <br>char sweep(void); <br>void wait_bouncing(void); <br>void wait_button_release(void); <br>char checkNumPad (void); <br> <br> <br><h2>checkNumPad.c</h2><br>//Yee Yik &amp; Andreas Lundgren <br>//Digital Project Fall 2001 <br>//Group 16 <br> <br>/*Keypad input program <br>&nbsp; Read input from keypad and send corresponding signal to LCD*/ <br>&nbsp; <br>#include "IO-reg.h" <br> <br>char sweep() { <br>&nbsp; <br>&nbsp; if ((PORTD &amp; 0x0F) == 0) <br>&nbsp; &nbsp; return 0; <br>&nbsp; &nbsp; <br>&nbsp; else if ((PORTD &amp; 0x01) != 0 ) <br>&nbsp; &nbsp; &nbsp; &nbsp; return 1; <br>&nbsp; &nbsp; <br>&nbsp; else if&nbsp; ((PORTD &amp; 0x02) != 0 ) <br>&nbsp; &nbsp; return 2; <br>&nbsp; &nbsp; <br>&nbsp; else if ((PORTD &amp; 0x04) != 0) <br>&nbsp; &nbsp; return 3; <br>&nbsp; &nbsp; <br>&nbsp; else if ((PORTD &amp; 0x08) != 0) <br>&nbsp; &nbsp; return 4; <br>&nbsp; &nbsp; <br>&nbsp; else <br>&nbsp; &nbsp; return 0;&nbsp; <br>&nbsp; &nbsp; <br>} //end of sweep() <br> <br>char checkNumPad () { <br>&nbsp; <br>&nbsp; &nbsp; char button = 0; <br>&nbsp; &nbsp; //set PORTB to 1000xxxx (ie set PB7 to 1) <br>&nbsp; &nbsp; PORTB &amp;= 0x0F;&nbsp; <br>&nbsp; &nbsp; PORTB |= 0x80; <br>&nbsp; <br>&nbsp; &nbsp; if ((button = sweep()) &gt; 0)&nbsp; //some button is pressed <br>&nbsp; &nbsp; &nbsp; return button; <br>&nbsp; <br>&nbsp; &nbsp; //set PORTB to 0100xxxx (ie set PB6 = 1) <br>&nbsp; &nbsp; PORTB &amp;= 0x0F;&nbsp; <br>&nbsp; &nbsp; PORTB |= 0x40; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; if ((button = sweep()) &gt; 0)&nbsp; //some button is pressed <br>&nbsp; &nbsp; &nbsp; return (button + 4); <br>&nbsp; <br>&nbsp; &nbsp; //set PORTB to 0010xxxx (ie set PB5 = 1) <br>&nbsp; &nbsp; PORTB &amp;= 0x0F;&nbsp; <br>&nbsp; &nbsp; PORTB |= 0x20; <br>&nbsp; <br>&nbsp; &nbsp; if ((button = sweep()) &gt; 0)&nbsp; //some button is pressed <br>&nbsp; &nbsp; &nbsp; return (button + 8); <br>&nbsp; <br>&nbsp; <br>&nbsp; &nbsp; //set PORTB to 0001xxxx (ie set PB4 = 1) <br>&nbsp; &nbsp; PORTB &amp;= 0x0F;&nbsp; <br>&nbsp; &nbsp; PORTB |= 0x10; <br>&nbsp; <br>&nbsp; &nbsp; if ((button = sweep()) &gt; 0)&nbsp; //some button is pressed <br>&nbsp; &nbsp; &nbsp; return (button + 12); <br>&nbsp; <br>&nbsp; return 0; <br>&nbsp; &nbsp; <br>} //end of checkNumPad() <br> <br>void wait_bouncing() { <br> <br>&nbsp; char i; <br>&nbsp; //For-loop is 26 clk:s, i=100 &amp; 8 MHz =&gt; 300 us <br>&nbsp; for (i = 100; i &gt;0; i--) <br>&nbsp; {} <br>} //end of wait_release() <br> <br>void wait_button_release() { <br>&nbsp; while (checkNumPad() &gt; 0) <br>&nbsp; {} <br>} //end of wait_button_release() <br> <br> <br><h2>LCD_driver.h</h2><br> <br>void write_character_position(char pos, char ch); <br>&nbsp; //write character ch at position pos on the LCD <br>void write_string_position(char pos, char *string); <br>&nbsp; //write string of character at position pos on the LCD <br>void write_long_position(char pos, long number); <br>&nbsp; //write long at position po on the LCD <br>void clear_display(void); <br>&nbsp; //clear display <br>void initLCD(void); <br> <br>//temporary <br>void put_character(char ch); <br> <br> <br><h2>LCD_driver.c</h2><br> <br>#include "int6811.h" <br>#include "io6811.h" <br> <br>char ch; <br>int x; <br> <br>void testBF (void) <br>{ <br>&nbsp; &nbsp; DDRC = 0; <br>&nbsp; &nbsp; PORTB &amp;= 0xF8;&nbsp; //retain other value in PB[3:7] <br>&nbsp; &nbsp; PORTB |= 0x03;&nbsp; //set E = 1, R/W = 1, RS = 0 <br>&nbsp; &nbsp; while (PORTC&amp;0x80) { }&nbsp; //wait until busy flag is off <br>} <br> <br>void put(char ch) <br>{ <br>&nbsp; &nbsp; PORTC = ch; <br>&nbsp; &nbsp; DDRC = 0xFF;&nbsp; //enable PORTC as output <br>&nbsp; &nbsp; PORTB |= 0x01; //set Enable to 1, ie read from PORTC <br>&nbsp; &nbsp; PORTB &amp;=0xFE;&nbsp; //set Enable to 0, other value unchange <br>&nbsp; &nbsp; DDRC = 0;&nbsp; &nbsp; &nbsp; //disable PORTC as output&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>} <br> <br>void set_command(void) <br>{ <br>&nbsp; &nbsp; PORTB &amp;= 0xF9;&nbsp; //write to instruction register, RS = 0, R/W = 0, E = x <br>} <br> <br>void set_character(void) <br>{ <br>&nbsp; &nbsp; PORTB |= 0x04; <br>&nbsp; &nbsp; PORTB &amp;= 0xFD;&nbsp; //write to data register, RS = 1, R/W = 0, E = x <br>} <br> <br>void put_command(char ch) <br>{ <br>&nbsp; &nbsp; testBF(); <br>&nbsp; &nbsp; set_command(); <br>&nbsp; &nbsp; put(ch); <br>} <br> <br>void put_character(char ch) <br>{ <br>&nbsp; &nbsp; testBF(); <br>&nbsp; &nbsp; set_character(); <br>&nbsp; &nbsp; put(ch); <br>} <br> <br>void wait_15ms(void) <br>{ <br>&nbsp; &nbsp; for (x = 4700; x != 0; x--); {} <br>&nbsp; &nbsp; //for-loop is 26 clk:s <br>} <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>void initLCD(void) <br>{ <br>&nbsp; &nbsp; wait_15ms(); <br>&nbsp; &nbsp; set_command(); <br>&nbsp; &nbsp; put(0x38); <br>&nbsp; &nbsp; wait_15ms(); <br>&nbsp; &nbsp; put(0x38); <br>&nbsp; &nbsp; wait_15ms(); <br>&nbsp; &nbsp; put(0x38); <br>&nbsp; &nbsp; put_command(0x38); <br>&nbsp; &nbsp; put_command(0x01); <br>&nbsp; &nbsp; put_command(0x06);&nbsp; &nbsp; <br>&nbsp; &nbsp; put_command(0x0C); <br>} <br> <br>void clear_display() <br>{ <br>&nbsp; put_command(0x01); <br>} <br> <br>void write_character_position(char pos, char ch) <br>{ <br>&nbsp; &nbsp; put_command(128+pos);&nbsp; &nbsp; <br>&nbsp; &nbsp; put_character(ch); <br>} <br> <br>void write_string_position(char pos, char *string) <br>{ <br>&nbsp; &nbsp; put_command(128+pos);&nbsp; &nbsp; //+0x40 <br>&nbsp; &nbsp; while (*string != 0) <br>&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; put_character(*string); <br>&nbsp; &nbsp; &nbsp; &nbsp; string++; <br>&nbsp; &nbsp; } <br>}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br> <br>void write_long_position(char pos, long number) <br>{ <br>&nbsp; &nbsp; char i = 15; <br>&nbsp; &nbsp; if (number == 0){&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; write_character_position(pos+i,'0'); <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; while (number != 0) <br>&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; write_character_position(pos+i,(number % 10) + '0'); <br>&nbsp; &nbsp; &nbsp; &nbsp; number = number / 10; <br>&nbsp; &nbsp; &nbsp; &nbsp; i--; <br>&nbsp; &nbsp; } <br>} <br> <br> <br><h2>measureMode.h</h2><br> <br>void startMeasure(); <br>void startShooting(); <br> <br> <br><h2>measureMode.c</h2><br> <br>//Enable time capture interrupt from PORTA[0:1] <br>#include "IO-reg.h" <br>#include "Vectors.h" <br>#include <intr6811.h> <br> <br>extern unsigned int nbrOverflow; <br>char waitingForInterrupt; <br>unsigned int foil1; <br>unsigned int foil2; <br>extern unsigned int deltaF; <br>char waitingForInterrupt2;&nbsp; &nbsp; <br>char inMeasureMode; <br>unsigned int i; <br>&nbsp; &nbsp; <br>/*MEASURE MODE*/&nbsp; &nbsp; <br>void startMeasure() { <br>&nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; waitingForInterrupt = 1; <br>&nbsp; &nbsp; foil1 = foil2 = 0; <br>&nbsp; &nbsp; inMeasureMode = 1; <br>&nbsp; <br>&nbsp; &nbsp; //Capture falling edge only <br>&nbsp; &nbsp; TCTL2 |= 0x0A; //xxxx 1x1x <br>&nbsp; &nbsp; TCTL2 &amp;= 0xFA; //xxxx x0x0 <br> <br>&nbsp; &nbsp; //clear flag first for PA0 &amp; PA1 <br>&nbsp; &nbsp; TFLG1 = 0x03; <br>&nbsp; &nbsp; //clear flag first for timer Overflow <br>&nbsp; &nbsp; TFLG2 = 0x80; <br> <br>&nbsp; &nbsp; //Enable PORTA[0:1] for time capture <br>&nbsp; &nbsp; TMSK1 |= 0x03; //xxxx xx11 <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; enable_interrupt(); <br>&nbsp; &nbsp; <br>//start <br>&nbsp; &nbsp; while (waitingForInterrupt == 1) /*ADD IF TIME PASSED IS TOO LONG, THEN RETURN*/ <br>&nbsp; &nbsp; { <br>&nbsp; &nbsp; &nbsp; &nbsp; wait_for_interrupt(); <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; disable_interrupt(); <br> <br>&nbsp; &nbsp; if (foil2 &gt;= foil1) <br>&nbsp; &nbsp; &nbsp; deltaF = foil2-foil1; <br>&nbsp; &nbsp; else { <br>&nbsp; &nbsp; &nbsp; deltaF = 0xFFFF - foil1 + foil2; <br>&nbsp; &nbsp; &nbsp; nbrOverflow--; <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; <br>}&nbsp; //end of startMeasure() <br> <br> <br>/*SHOOTING MODE*/ <br>void startShooting() { <br> <br>&nbsp; waitingForInterrupt2 = 1; <br>&nbsp; foil1 = 0; <br>&nbsp; inMeasureMode = 0; <br>&nbsp; <br>&nbsp; //Turn flash trigger off. <br>&nbsp; PORTD &amp;= 0xEF; <br>&nbsp; <br>&nbsp; //Capture falling edge only <br>&nbsp; TCTL2 |= 0x0A; //xxxx 1x1x <br>&nbsp; TCTL2 &amp;= 0xFA; //xxxx x0x0 <br>&nbsp; <br>&nbsp; //clear flag first for PA0 <br>&nbsp; TFLG1 = 0x01; <br>&nbsp; //clear flag first for timer Overflow <br>&nbsp; TFLG2 = 0x80; <br>&nbsp; <br>&nbsp; //Enable PORTA[0] for time capture <br>&nbsp; TMSK1 |= 0x01; //xxxx xxx1 <br>&nbsp; <br>&nbsp; //set PA4 as output campare pin <br>&nbsp; OC1M |= 0x10;&nbsp; <br>&nbsp; &nbsp; <br>&nbsp; enable_interrupt(); <br>&nbsp; <br>//start&nbsp; <br> <br>&nbsp; while(waitingForInterrupt2 == 1) { <br>&nbsp; &nbsp; wait_for_interrupt(); <br>&nbsp; } <br> <br>&nbsp; disable_interrupt(); <br>&nbsp; for (i=0; i &lt; 1000; i++){} <br>&nbsp; //Turn flash trigger off. <br>&nbsp; PORTD &amp;= 0xEF; <br>} <br> <br>//Timer Ovwerflow <br>interrupt void TO_interrupt() <br>{ <br>&nbsp; &nbsp; nbrOverflow++; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; //clear flag Timer Overflow <br>&nbsp; &nbsp; TFLG2 = 0x80; <br>} <br> <br>//PA0, first foil, interrupt which cause the system to start counting <br>interrupt void IC3_interrupt() <br>{ <br>&nbsp; &nbsp; //clear flag Timer Overflow <br>&nbsp; &nbsp; TFLG2 = 0x80; <br> <br>&nbsp; &nbsp; foil1 = TIC3;&nbsp; &nbsp; //store captured time from TIC 3 to foil1 <br> <br>&nbsp; &nbsp; if (! inMeasureMode) { <br>&nbsp; &nbsp; &nbsp; if (nbrOverflow &gt; 0) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TOC4 = foil1; <br>&nbsp; &nbsp; &nbsp; else <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TOC4 = deltaF + foil1; <br>&nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; //clear flag first for PA4 <br>&nbsp; &nbsp; &nbsp; TFLG1 = 0x10; <br>&nbsp; &nbsp; &nbsp; //Enable OC4 interrupt <br>&nbsp; &nbsp; &nbsp; TMSK1 |= 0x10; <br>&nbsp; &nbsp; }&nbsp; //end of if (!inMeasureMode)&nbsp; &nbsp; <br>&nbsp; &nbsp; else { <br>&nbsp; &nbsp; &nbsp; //Enable Timer Overflow <br>&nbsp; &nbsp; &nbsp; TMSK2 |= 0x80; <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; //clear flag first for PA0 <br>&nbsp; &nbsp; TFLG1 = 0x01; <br>&nbsp; &nbsp; //Disable IC3 interrupt <br>&nbsp; &nbsp; TMSK1 &amp;= 0xFE; //xxxx xxx0 <br> <br>} <br> <br>//end measurement <br>interrupt void IC2_interrupt() <br>{ <br>&nbsp; &nbsp; foil2 = TIC2; <br> <br>&nbsp; &nbsp; //clear flag first for PA1 <br>&nbsp; &nbsp; TFLG1 = 0x02; <br>&nbsp; &nbsp; //Disable IC2 interrupts <br>&nbsp; &nbsp; TMSK1 &amp;= 0xFD; //xxxx xx0x <br>&nbsp; &nbsp; //Disable Timer Ovewflow <br>&nbsp; &nbsp; TMSK2 &amp;= 0x7F; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; waitingForInterrupt = 0; <br>} <br> <br>interrupt void OC4_interrupt() <br>{ <br>&nbsp; &nbsp; foil2 = TCNT; <br> <br>&nbsp; &nbsp; if (nbrOverflow == 0) { <br>&nbsp; &nbsp; &nbsp; PORTD |= 0x10;&nbsp; //Turn flash trigger on. <br>&nbsp; &nbsp; &nbsp; waitingForInterrupt2 = 0; //Exit while-loop in startShooting() <br>&nbsp; &nbsp; &nbsp; //Disable OC4 interrupts <br>&nbsp; &nbsp; &nbsp; TMSK1 &amp;= 0xEF; //xxx0 xxxx <br>&nbsp; &nbsp; } else if (nbrOverflow == 1) { <br>&nbsp; &nbsp; &nbsp; TOC4 = deltaF + foil2; <br>&nbsp; &nbsp; &nbsp; nbrOverflow--; <br>&nbsp; &nbsp; } else { <br>&nbsp; &nbsp; &nbsp; TOC4 = foil2; <br>&nbsp; &nbsp; &nbsp; nbrOverflow--; <br>&nbsp; &nbsp; } <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; //clear flag first for PA4 <br>&nbsp; &nbsp; TFLG1 = 0x10; <br>} <br> <br> <br>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </intr6811.h><h3>CSTARTUP.S07</h3>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; This module contains the 68HC11 startup routine and&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; must usually be tailored to suit special hardware needs&nbsp; &nbsp; &nbsp; * <br>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; Note:&nbsp; The routine ?SEG_INIT_L07 is now included in CSTARTUP * <br>*&nbsp; The size of stack is set in the link-file (lnk6???.xcl)&nbsp; &nbsp; &nbsp; * <br>*&nbsp; The segment INTVEC is declared COMMON&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; Version:&nbsp; &nbsp; 3.30 [IHAW 11/Feb/92]&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; Revised:&nbsp; &nbsp; 3.31 [IHAW 07/Jul/92] Bug in stack init&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; Revised:&nbsp; &nbsp; 3.32 [IJAR 06/Mar/93] Startup code for K4 added&nbsp; * <br>*&nbsp; Revised:&nbsp; &nbsp; 4.11 [IMAI 29/Oct/96] Updated for ICC6811 4.11&nbsp; * <br>*&nbsp; [SN 19/jan/98] Updated for Digitala projekt&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>&nbsp; &nbsp; NAME&nbsp; &nbsp; CSTARTUP <br>&nbsp; &nbsp; EXTERN&nbsp; &nbsp; ?C_EXIT&nbsp; &nbsp; ; Where to go when program is done <br>&nbsp; <br>&nbsp; &nbsp; EXTERN&nbsp; &nbsp; main&nbsp; &nbsp; &nbsp; &nbsp; ; Where to begin execution <br> <br>*---------------------------------------------------------------* <br>*&nbsp; CSTACK - The C stack segment&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; Please look in the link-file ??????.xcl how to increment&nbsp; &nbsp; * <br>*&nbsp; the stack without having to reassemble cstartup.s07 !&nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br> <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; CSTACK <br>&nbsp; &nbsp; RMB&nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; &nbsp; ; A bare minimum !! <br> <br>*---------------------------------------------------------------* <br>*&nbsp; Forward declarations of segments used in initialization&nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br> <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; UDATA0 <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; UDATA1 <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; IDATA0 <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; IDATA1 <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; ECSTR <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; WCSTR <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; CDATA0 <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; CDATA1 <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; CCSTR <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; CONST <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; CSTR <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; TEMP <br> <br>&nbsp; &nbsp; <br>*---------------------------------------------------------------* <br>*&nbsp; RCODE - Where the program actually starts&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; RCODE <br>init_C:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; LDS&nbsp; &nbsp; #$00FF&nbsp; &nbsp; ; #$01FF for 68HC11E9 <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; #$02FF for 68HC11E20 <br> <br>*---------------------------------------------------------------* <br>* If the 68HC11 OPTION register MUST be modified, here is the&nbsp; * <br>* place to do it in order to meet the 64-cycle requirement.&nbsp; &nbsp; * <br>* You can also do it in the beginning of main if You don't use&nbsp; * <br>* seg_init&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br> <br>&nbsp; &nbsp; LDAA #$00&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;store value 00000000 in TMSK2 to set the speed of TCNT. (500 ns) <br>&nbsp; &nbsp; STAA $1024 <br> <br>*---------------------------------------------------------------* <br>* If it is not a requirement that static/global data is set&nbsp; &nbsp; * <br>* to zero or to some explicit value at startup, the next line&nbsp; * <br>* of code can be deleted.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; BSR&nbsp; &nbsp; seg_init <br> <br>*---------------------------------------------------------------* <br>* If hardware must be initiated from assembly or if interrupts&nbsp; * <br>* should be on when reaching main, this is the place to insert&nbsp; * <br>* such code.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br> <br>&nbsp; &nbsp; JSR&nbsp; &nbsp; main&nbsp; &nbsp; &nbsp; &nbsp; main() <br> <br>*---------------------------------------------------------------* <br>* Now when we are ready with our C program (usually 6811&nbsp; &nbsp; &nbsp; &nbsp; * <br>* programs are continouous) we must perform a system-dependent&nbsp; * <br>* action.&nbsp; In this simple case we jump to ?C_EXIT.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>* DO NOT CHANGE NEXT LINE OF CSTARTUP IF YOU WANT TO RUN YOUR&nbsp; * <br>* SOFTWARE WITH THE AID OF THE C-SPY HLL DEBUGGER.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>&nbsp; &nbsp; JMP&nbsp; &nbsp; ?C_EXIT&nbsp; &nbsp; <br> <br> <br>*---------------------------------------------------------------* <br>*&nbsp; Copy initialized PROMmed code to shadow RAM and clear&nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; uninitialized variables.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>seg_init: <br> <br>*---------------------------------------------------------------* <br>*&nbsp; Zero out UDATA segments&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br> <br>&nbsp; &nbsp; LDD&nbsp; &nbsp; #.SFE.(UDATA0) <br>&nbsp; &nbsp; SUBD&nbsp; &nbsp; #.SFB.(UDATA0) <br>&nbsp; &nbsp; BEQ&nbsp; &nbsp; SKIP00 <br>&nbsp; &nbsp; XGDY <br>&nbsp; &nbsp; LDX&nbsp; &nbsp; #.SFB.(UDATA0) <br>&nbsp; &nbsp; BSR&nbsp; &nbsp; zero_mem <br>SKIP00 <br> <br>&nbsp; &nbsp; LDD&nbsp; &nbsp; #.SFE.(UDATA1) <br>&nbsp; &nbsp; SUBD&nbsp; &nbsp; #.SFB.(UDATA1) <br>&nbsp; &nbsp; BEQ&nbsp; &nbsp; SKIP01 <br>&nbsp; &nbsp; XGDY <br>&nbsp; &nbsp; LDX&nbsp; &nbsp; #.SFB.(UDATA1) <br>&nbsp; &nbsp; BSR&nbsp; &nbsp; zero_mem <br>SKIP01 <br> <br>*---------------------------------------------------------------* <br>* Copy CDATA segments into IDATA segments&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br> <br>&nbsp; &nbsp; LDD&nbsp; &nbsp; #.SFE.(CDATA0) <br>&nbsp; &nbsp; SUBD&nbsp; &nbsp; #.SFB.(CDATA0) <br>&nbsp; &nbsp; BEQ&nbsp; &nbsp; SKIP02 <br>&nbsp; &nbsp; LDX&nbsp; &nbsp; #.SFB.(CDATA0) <br>&nbsp; &nbsp; LDY&nbsp; &nbsp; #.SFB.(IDATA0) <br>&nbsp; &nbsp; BSR&nbsp; &nbsp; copy_mem <br>SKIP02 <br> <br>&nbsp; &nbsp; LDD&nbsp; &nbsp; #.SFE.(CDATA1) <br>&nbsp; &nbsp; SUBD&nbsp; &nbsp; #.SFB.(CDATA1) <br>&nbsp; &nbsp; BEQ&nbsp; &nbsp; SKIP03 <br>&nbsp; &nbsp; LDX&nbsp; &nbsp; #.SFB.(CDATA1) <br>&nbsp; &nbsp; LDY&nbsp; &nbsp; #.SFB.(IDATA1) <br>&nbsp; &nbsp; BSR&nbsp; &nbsp; copy_mem <br>SKIP03 <br> <br>*---------------------------------------------------------------* <br>* Copy CCSTR into ECSTR&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br> <br>&nbsp; &nbsp; LDD&nbsp; &nbsp; #.SFE.(CCSTR) <br>&nbsp; &nbsp; SUBD&nbsp; &nbsp; #.SFB.(CCSTR) <br>&nbsp; &nbsp; BEQ&nbsp; &nbsp; SKIP04 <br>&nbsp; &nbsp; LDX&nbsp; &nbsp; #.SFB.(CCSTR) <br>&nbsp; &nbsp; LDY&nbsp; &nbsp; #.SFB.(ECSTR) <br>&nbsp; &nbsp; BSR&nbsp; &nbsp; copy_mem <br>SKIP04 <br>&nbsp; &nbsp; RTS&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; End of initialization <br> <br>*---------------------------------------------------------------* <br>* Clear memory&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>zero_mem: <br>&nbsp; &nbsp; CLR&nbsp; &nbsp; 0,X <br>&nbsp; &nbsp; INX <br>&nbsp; &nbsp; DEY <br>&nbsp; &nbsp; BNE&nbsp; &nbsp; zero_mem <br>&nbsp; &nbsp; RTS <br> <br>*---------------------------------------------------------------* <br>*&nbsp; Copy memory&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; Copy (X) --&gt; (Y), counter in D&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>copy_mem: <br>&nbsp; &nbsp; PSHA <br>&nbsp; &nbsp; LDAA&nbsp; &nbsp; 0,X <br>&nbsp; &nbsp; STAA&nbsp; &nbsp; 0,Y <br>&nbsp; &nbsp; PULA&nbsp; &nbsp; <br>&nbsp; &nbsp; INX <br>&nbsp; &nbsp; INY <br>&nbsp; &nbsp; SUBD&nbsp; &nbsp; #1 <br>&nbsp; &nbsp; BNE&nbsp; &nbsp; copy_mem <br>&nbsp; &nbsp; RTS <br> <br> <br> <br>*---------------------------------------------------------------* <br>*&nbsp; Interrupt vectors must be inserted by the user.&nbsp; &nbsp; Here we&nbsp; * <br>*&nbsp; only used RESET.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br> <br>&nbsp; &nbsp; COMMON&nbsp; &nbsp; INTVEC <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ; Assuming start address = FFD6 for 68HC11 <br>&nbsp; &nbsp; RMB&nbsp; &nbsp; 40 <br> <br>&nbsp; &nbsp; FDB&nbsp; &nbsp; init_C <br> <br>&nbsp; &nbsp; ENDMOD&nbsp; &nbsp; init_C&nbsp; &nbsp; &nbsp; &nbsp; ; 'init_C' is program entry address <br> <br>*---------------------------------------------------------------* <br>* Function/module: exit(int code)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>* When C-SPY is used this code will automatically be replaced&nbsp; * <br>* by a 'debug' version of exit().&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>&nbsp; &nbsp; MODULE&nbsp; &nbsp; exit <br> <br>&nbsp; &nbsp; PUBLIC&nbsp; &nbsp; exit <br>&nbsp; &nbsp; PUBLIC&nbsp; &nbsp; ?C_EXIT <br> <br>&nbsp; &nbsp; RSEG&nbsp; &nbsp; RCODE <br> <br>?C_EXIT: <br>exit: <br>*---------------------------------------------------------------* <br>* The next line could be replaced by user defined code.&nbsp; &nbsp; &nbsp; &nbsp; * <br>*---------------------------------------------------------------* <br>end_loop: <br>&nbsp; &nbsp; BRA&nbsp; &nbsp; end_loop <br> <br>&nbsp; &nbsp; END <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br>/*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - Vectors.h - <br> <br>&nbsp; This file defines the interrupt vector addresses of the 68HC11 <br>&nbsp; and appropriate function names that can be used with the interrupts. <br>&nbsp; It is assumed that the segment INTVEC is located at address 0xFFD6. <br>*/ <br> <br>#pragma language=extended <br> <br>#define INTVEC_START&nbsp; &nbsp; 0&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Default for 68HC11 (must be matched <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; to the value used at link-time)&nbsp; */ <br> <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=======================*/ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Interrupt Definitions */ <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /*=======================*/ <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* SCI Serial Communication Interface */ <br>interrupt [INTVEC_START +&nbsp; 0] void SCI_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* SPI Serial Transfer Complete */ <br>interrupt [INTVEC_START +&nbsp; 2] void SPI_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Pulse Accumulator Input Edge */ <br>interrupt [INTVEC_START +&nbsp; 4] void PAIE_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Pulse Accumulator Overflow */ <br>interrupt [INTVEC_START +&nbsp; 6] void PAO_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Overflow */ <br>interrupt [INTVEC_START +&nbsp; 8] void TO_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Output Compare 5 */ <br>interrupt [INTVEC_START + 10] void OC5_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Output Compare 4 */ <br>interrupt [INTVEC_START + 12] void OC4_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Output Compare 3 */ <br>interrupt [INTVEC_START + 14] void OC3_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Output Compare 2 */ <br>interrupt [INTVEC_START + 16] void OC2_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Output Compare 1 */ <br>interrupt [INTVEC_START + 18] void OC1_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Input Compare 4 */ <br>interrupt [INTVEC_START + 10] void IC4_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Input Compare 3 */ <br>interrupt [INTVEC_START + 20] void IC3_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Input Compare 2 */ <br>interrupt [INTVEC_START + 22] void IC2_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Timer Input Compare 1 */ <br>interrupt [INTVEC_START + 24] void IC1_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Real Time Interrupt */ <br>interrupt [INTVEC_START + 26] void RTI_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Interrupt ReQuest */ <br>interrupt [INTVEC_START + 28] void IRQ_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* eXtended Interrupt ReQuest */ <br>interrupt [INTVEC_START + 30] void XIRQ_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* SoftWare Interrupt */ <br>interrupt [INTVEC_START + 32] void Software_interrupt(void); <br> <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* Illegal Opcode Trap */ <br>interrupt [INTVEC_START + 34] void Illegal_Opcode(void); <br> <br>/* Watchdog and Clock Monitor are defined i cstartup.s07 */&nbsp; <br> <br> <br><h2>/* FILENAME: IO-reg.h</h2><br> * <br> * Register and bit macro definitions for <br> * all HC11 types in A and E series. <br> * <br> * Uppdatering 990917: volatile bara f�r PORTCL, SPSR och SCSR. <br> * <br> */ <br> <br>#define REG_BASE 0x1000 <br> <br>#define PORTA&nbsp; (*(unsigned char *)(REG_BASE + 0x00)) <br>#define PIOC&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x02)) <br>#define PORTC&nbsp; (*(unsigned char *)(REG_BASE + 0x03)) <br>#define PORTB&nbsp; (*(unsigned char *)(REG_BASE + 0x04)) <br>#define PORTCL&nbsp; (*(volatile unsigned char *)(REG_BASE + 0x05)) <br>#define DDRC&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x07)) <br>#define PORTD&nbsp; (*(unsigned char *)(REG_BASE + 0x08)) <br>#define DDRD&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x09)) <br>#define PORTE&nbsp; (*(unsigned char *)(REG_BASE + 0x0A)) <br>#define CFORC&nbsp; (*(unsigned char *)(REG_BASE + 0x0B)) <br>#define OC1M&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x0C)) <br>#define OC1D&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x0D)) <br>#define TCNT&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x0E)) <br>#define TIC1&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x10)) <br>#define TIC2&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x12)) <br>#define TIC3&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x14)) <br>#define TIC4&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x1E)) <br>#define TOC1&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x16)) <br>#define TOC2&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x18)) <br>#define TOC3&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x1A)) <br>#define TOC4&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x1C)) <br>#define TOC5&nbsp; &nbsp; (*(unsigned int *)(REG_BASE + 0x1E)) <br>#define TI4/O4&nbsp; (*(unsigned int *)(REG_BASE + 0x1E)) <br>#define TCTL1&nbsp; (*(unsigned char *)(REG_BASE + 0x20)) <br>#define TCTL2&nbsp; (*(unsigned char *)(REG_BASE + 0x21)) <br>#define TMSK1&nbsp; (*(unsigned char *)(REG_BASE + 0x22)) <br>#define TFLG1&nbsp; (*(unsigned char *)(REG_BASE + 0x23)) <br>#define TMSK2&nbsp; (*(unsigned char *)(REG_BASE + 0x24)) <br>#define TFLG2&nbsp; (*(unsigned char *)(REG_BASE + 0x25)) <br>#define PACTL&nbsp; (*(unsigned char *)(REG_BASE + 0x26)) <br>#define PACNT&nbsp; (*(unsigned char *)(REG_BASE + 0x27)) <br>#define SPCR&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x28)) <br>#define SPSR&nbsp; &nbsp; (*(volatile unsigned char *)(REG_BASE + 0x29)) <br>#define SPDR&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x2A)) <br>#define BAUD&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x2B)) <br>#define SCCR1&nbsp; (*(unsigned char *)(REG_BASE + 0x2C)) <br>#define SCCR2&nbsp; (*(unsigned char *)(REG_BASE + 0x2D)) <br>#define SCSR&nbsp; &nbsp; (*(volatile unsigned char *)(REG_BASE + 0x2E)) <br>#define SCDR&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x2F)) <br>#define ADCTL&nbsp; (*(unsigned char *)(REG_BASE + 0x30)) <br>#define ADR1&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x31)) <br>#define ADR2&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x32)) <br>#define ADR3&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x33)) <br>#define ADR4&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x34)) <br>#define BPROT&nbsp; (*(unsigned char *)(REG_BASE + 0x35)) <br>#define EPROG&nbsp; (*(unsigned char *)(REG_BASE + 0x36)) <br>#define OPTION&nbsp; (*(unsigned char *)(REG_BASE + 0x39)) <br>#define COPRST&nbsp; (*(unsigned char *)(REG_BASE + 0x3A)) <br>#define PPROG&nbsp; (*(unsigned char *)(REG_BASE + 0x3B)) <br>#define HPRIO&nbsp; (*(unsigned char *)(REG_BASE + 0x3C)) <br>#define INIT&nbsp; &nbsp; (*(unsigned char *)(REG_BASE + 0x3D)) <br>#define TEST1&nbsp; (*(unsigned char *)(REG_BASE + 0x3E)) <br>#define CONFIG&nbsp; (*(unsigned char *)(REG_BASE + 0x3F)) <br> <br>/* Bit names for general use */ <br>#define bit7&nbsp; &nbsp; 0x80 <br>#define bit6&nbsp; &nbsp; 0x40 <br>#define bit5&nbsp; &nbsp; 0x20 <br>#define bit4&nbsp; &nbsp; 0x10 <br>#define bit3&nbsp; &nbsp; 0x08 <br>#define bit2&nbsp; &nbsp; 0x04 <br>#define bit1&nbsp; &nbsp; 0x02 <br>#define bit0&nbsp; &nbsp; 0x01 <br> <br>/* PORTA bit definitions 0x00 */ <br>#define PA7&nbsp; &nbsp; bit7 <br>#define PA6&nbsp; &nbsp; bit6 <br>#define PA5&nbsp; &nbsp; bit5 <br>#define PA4&nbsp; &nbsp; bit4 <br>#define PA3&nbsp; &nbsp; bit3 <br>#define PA2&nbsp; &nbsp; bit2 <br>#define PA1&nbsp; &nbsp; bit1 <br>#define PA0&nbsp; &nbsp; bit0 <br> <br>/* PIOC bit definitions 0x02 */ <br>#define STAF&nbsp; &nbsp; bit7 <br>#define STAI&nbsp; &nbsp; bit6 <br>#define CWOM&nbsp; &nbsp; bit5 <br>#define HNDS&nbsp; &nbsp; bit4 <br>#define OIN&nbsp; &nbsp; bit3 <br>#define PLS&nbsp; &nbsp; bit2 <br>#define EGA&nbsp; &nbsp; bit1 <br>#define INVB&nbsp; &nbsp; bit0 <br> <br>/* PORTC bit definitions 0x03 */ <br>#define PC7&nbsp; &nbsp; bit7 <br>#define PC6&nbsp; &nbsp; bit6 <br>#define PC5&nbsp; &nbsp; bit5 <br>#define PC4&nbsp; &nbsp; bit4 <br>#define PC3&nbsp; &nbsp; bit3 <br>#define PC2&nbsp; &nbsp; bit2 <br>#define PC1&nbsp; &nbsp; bit1 <br>#define PC0&nbsp; &nbsp; bit0 <br> <br>/* PORTB bit definitions 0x04 */ <br>#define PB7&nbsp; &nbsp; bit7 <br>#define PB6&nbsp; &nbsp; bit6 <br>#define PB5&nbsp; &nbsp; bit5 <br>#define PB4&nbsp; &nbsp; bit4 <br>#define PB3&nbsp; &nbsp; bit3 <br>#define PB2&nbsp; &nbsp; bit2 <br>#define PB1&nbsp; &nbsp; bit1 <br>#define PB0&nbsp; &nbsp; bit0 <br> <br>/* PORTCL bit definitions 0x05 */ <br>#define PCL7&nbsp; &nbsp; bit7 <br>#define PCL6&nbsp; &nbsp; bit6 <br>#define PCL5&nbsp; &nbsp; bit5 <br>#define PCL4&nbsp; &nbsp; bit4 <br>#define PCL3&nbsp; &nbsp; bit3 <br>#define PCL2&nbsp; &nbsp; bit2 <br>#define PCL1&nbsp; &nbsp; bit1 <br>#define PCL0&nbsp; &nbsp; bit0 <br> <br>/* DDRC bit definitions 0x07 */ <br>#define DDC7&nbsp; &nbsp; bit7 <br>#define DDC6&nbsp; &nbsp; bit6 <br>#define DDC5&nbsp; &nbsp; bit5 <br>#define DDC4&nbsp; &nbsp; bit4 <br>#define DDC3&nbsp; &nbsp; bit3 <br>#define DDC2&nbsp; &nbsp; bit2 <br>#define DDC1&nbsp; &nbsp; bit1 <br>#define DDC0&nbsp; &nbsp; bit0 <br> <br>/* PORTD bit definitions 0x08 */ <br>#define PD5&nbsp; &nbsp; bit5 <br>#define PD4&nbsp; &nbsp; bit4 <br>#define PD3&nbsp; &nbsp; bit3 <br>#define PD2&nbsp; &nbsp; bit2 <br>#define PD1&nbsp; &nbsp; bit1 <br>#define PD0&nbsp; &nbsp; bit0 <br> <br>/* DDRD bit definitions 0x09 */ <br>#define DDD5&nbsp; &nbsp; bit5 <br>#define DDD4&nbsp; &nbsp; bit4 <br>#define DDD3&nbsp; &nbsp; bit3 <br>#define DDD2&nbsp; &nbsp; bit2 <br>#define DDD1&nbsp; &nbsp; bit1 <br>#define DDD0&nbsp; &nbsp; bit0 <br> <br>/* PORTE bit definitions 0x0A */ <br>#define PE7&nbsp; &nbsp; bit7 <br>#define PE6&nbsp; &nbsp; bit6 <br>#define PE5&nbsp; &nbsp; bit5 <br>#define PE4&nbsp; &nbsp; bit4 <br>#define PE3&nbsp; &nbsp; bit3 <br>#define PE2&nbsp; &nbsp; bit2 <br>#define PE1&nbsp; &nbsp; bit1 <br>#define PE0&nbsp; &nbsp; bit0 <br> <br>/* CFORC bit definitions 0x0B */ <br>#define FOC1&nbsp; &nbsp; bit7 <br>#define FOC2&nbsp; &nbsp; bit6 <br>#define FOC3&nbsp; &nbsp; bit5 <br>#define FOC4&nbsp; &nbsp; bit4 <br>#define FOC5&nbsp; &nbsp; bit3 <br> <br>/* OC1M bit definitions 0x0C */ <br>#define OC1M7&nbsp; bit7 <br>#define OC1M6&nbsp; bit6 <br>#define OC1M5&nbsp; bit5 <br>#define OC1M4&nbsp; bit4 <br>#define OC1M3&nbsp; bit3 <br> <br>/* OC1D bit definitions 0x0D */ <br>#define OC1D7&nbsp; bit7 <br>#define OC1D6&nbsp; bit6 <br>#define OC1D5&nbsp; bit5 <br>#define OC1D4&nbsp; bit4 <br>#define OC1D3&nbsp; bit3 <br> <br>/* TCTL1 bit definition 0x20 */ <br>#define OM2&nbsp; &nbsp; bit7 <br>#define OL2&nbsp; &nbsp; bit6 <br>#define OM3&nbsp; &nbsp; bit5 <br>#define OL3&nbsp; &nbsp; bit4 <br>#define OM4&nbsp; &nbsp; bit3 <br>#define OL4&nbsp; &nbsp; bit2 <br>#define OM5&nbsp; &nbsp; bit1 <br>#define OL5&nbsp; &nbsp; bit0 <br> <br>/* TCTL2 bit definitions 0x21 */ <br>#define EDG4B&nbsp; bit7 <br>#define EDG4A&nbsp; bit6 <br>#define EDG1B&nbsp; bit5 <br>#define EDG1A&nbsp; bit4 <br>#define EDG2B&nbsp; bit3 <br>#define EDG2A&nbsp; bit2 <br>#define EDG3B&nbsp; bit1 <br>#define EDG3A&nbsp; bit0 <br> <br>/* TMSK1 bit definitions 0x22 */ <br>#define OC1I&nbsp; &nbsp; bit7 <br>#define OC2I&nbsp; &nbsp; bit6 <br>#define OC3I&nbsp; &nbsp; bit5 <br>#define OC4I&nbsp; &nbsp; bit4 <br>#define I4O5I&nbsp; bit3 <br>#define IC1I&nbsp; &nbsp; bit2 <br>#define IC2I&nbsp; &nbsp; bit1 <br>#define IC3I&nbsp; &nbsp; bit0 <br> <br>/* TFLG1 bit definitions 0x23 */ <br>#define OC1F&nbsp; &nbsp; bit7 <br>#define OC2F&nbsp; &nbsp; bit6 <br>#define OC3F&nbsp; &nbsp; bit5 <br>#define OC4F&nbsp; &nbsp; bit4 <br>#define I4O5F&nbsp; bit3 <br>#define IC1F&nbsp; &nbsp; bit2 <br>#define IC2F&nbsp; &nbsp; bit1 <br>#define IC3F&nbsp; &nbsp; bit0 <br> <br>/* TMSK2 bit definitions 0x24 */ <br>#define TOI&nbsp; &nbsp; bit7 <br>#define RTII&nbsp; &nbsp; bit6 <br>#define PAOVI&nbsp; bit5 <br>#define PAII&nbsp; &nbsp; bit4 <br>#define PR1&nbsp; &nbsp; bit1 <br>#define PR0&nbsp; &nbsp; bit0 <br> <br>/* TFLG2 bit definitions 0x25 */ <br>#define TOF&nbsp; &nbsp; bit7 <br>#define RTIF&nbsp; &nbsp; bit6 <br>#define PAOVF&nbsp; bit5 <br>#define PAIF&nbsp; &nbsp; bit4 <br> <br>/* PACTL bit definitions 0x26 */ <br>#define DDRA7&nbsp; bit7 <br>#define PAEN&nbsp; &nbsp; bit6 <br>#define PAMOD&nbsp; bit5 <br>#define PEDGE&nbsp; bit4 <br>#define DDRA3&nbsp; bit3 <br>#define I4O5&nbsp; &nbsp; bit2 <br>#define RTR1&nbsp; &nbsp; bit1 <br>#define RTR0&nbsp; &nbsp; bit0 <br> <br>/* SPCR bit definitions 0x28 */ <br>#define SPIE&nbsp; &nbsp; bit7 <br>#define SPE&nbsp; &nbsp; bit6 <br>#define DWOM&nbsp; &nbsp; bit5 <br>#define MSTR&nbsp; &nbsp; bit4 <br>#define CPOL&nbsp; &nbsp; bit3 <br>#define CPHA&nbsp; &nbsp; bit2 <br>#define SPR1&nbsp; &nbsp; bit1 <br>#define SPR0&nbsp; &nbsp; bit0 <br> <br>/* SPSR bit definitions 0x29 */ <br>#define SPIF&nbsp; &nbsp; bit7 <br>#define WCOL&nbsp; &nbsp; bit6 <br>#define MODF&nbsp; &nbsp; bit4 <br> <br>/* BAUD bit definitions 0x2B */ <br>#define TCLR&nbsp; &nbsp; bit7 <br>#define SCP2&nbsp; &nbsp; bit6 <br>#define SCP1&nbsp; &nbsp; bit5 <br>#define SCP0&nbsp; &nbsp; bit4 <br>#define RCKB&nbsp; &nbsp; bit3 <br>#define SCR2&nbsp; &nbsp; bit2 <br>#define SCR1&nbsp; &nbsp; bit1 <br>#define SCR0&nbsp; &nbsp; bit0 <br> <br>/* SCCR1 bit definition 0x2C */ <br>#define R8&nbsp; &nbsp; &nbsp; bit7 <br>#define T8&nbsp; &nbsp; &nbsp; bit6 <br>#define M&nbsp; &nbsp; &nbsp; bit4 <br>#define WAKE&nbsp; &nbsp; bit3 <br> <br>/* SCCR2 bit definitions 0x2D */ <br>#define TIE&nbsp; &nbsp; bit7 <br>#define TCIE&nbsp; &nbsp; bit6 <br>#define RIE&nbsp; &nbsp; bit5 <br>#define ILIE&nbsp; &nbsp; bit4 <br>#define TE&nbsp; &nbsp; &nbsp; bit3 <br>#define RE&nbsp; &nbsp; &nbsp; bit2 <br>#define RWU&nbsp; &nbsp; bit1 <br>#define SBK&nbsp; &nbsp; bit0 <br> <br>/* SCSR&nbsp; bit definitions 0x2E */ <br>#define TDRE&nbsp; &nbsp; bit7 <br>#define TC&nbsp; &nbsp; &nbsp; bit6 <br>#define RDRF&nbsp; &nbsp; bit5 <br>#define IDLE&nbsp; &nbsp; bit4 <br>#define OR&nbsp; &nbsp; &nbsp; bit3 <br>#define NF&nbsp; &nbsp; &nbsp; bit2 <br>#define FE&nbsp; &nbsp; &nbsp; bit1 <br> <br>/* SCDR bit definitions 0x2F */ <br>#define R7T7&nbsp; &nbsp; bit7 <br>#define R6T6&nbsp; &nbsp; bit6 <br>#define R5T5&nbsp; &nbsp; bit5 <br>#define R4T4&nbsp; &nbsp; bit4 <br>#define R3T3&nbsp; &nbsp; bit3 <br>#define R2T2&nbsp; &nbsp; bit2 <br>#define R1T1&nbsp; &nbsp; bit1 <br>#define R0T0&nbsp; &nbsp; bit0 <br> <br>/* ADCTL bit definitions 0x30 */ <br>#define CCF&nbsp; &nbsp; bit7 <br>#define SCAN&nbsp; &nbsp; bit5 <br>#define MULT&nbsp; &nbsp; bit4 <br>#define CD&nbsp; &nbsp; &nbsp; bit3 <br>#define CC&nbsp; &nbsp; &nbsp; bit2 <br>#define CB&nbsp; &nbsp; &nbsp; bit1 <br>#define CA&nbsp; &nbsp; &nbsp; bit0 <br> <br>/* BPROT bit definitions 0x35 */ <br>#define PTCON&nbsp; bit4 <br>#define BPRT3&nbsp; bit3 <br>#define BPRT2&nbsp; bit2 <br>#define BPRT1&nbsp; bit1 <br>#define BPRT0&nbsp; bit0 <br> <br>/* EPROG bit definitions 0x36&nbsp; &nbsp; &nbsp; MC68HC(7)11E20 only */ <br>#define MBE&nbsp; &nbsp; bit7 <br>/* ELAT defined in PPROG */ <br>#define EXCOL&nbsp; bit4 <br>#define EXROW&nbsp; bit3 <br>#define T1&nbsp; &nbsp; &nbsp; bit2 <br>#define T0&nbsp; &nbsp; &nbsp; bit1 <br>#define PGM&nbsp; &nbsp; bit0 <br> <br>/* OPTION bit definitions 0x39 */ <br>#define ADPU&nbsp; &nbsp; bit7 <br>#define CSEL&nbsp; &nbsp; bit6 <br>#define IRQE&nbsp; &nbsp; bit5 <br>#define DLY&nbsp; &nbsp; bit4 <br>#define CME&nbsp; &nbsp; bit3 <br>#define CR1&nbsp; &nbsp; bit1 <br>#define CR0&nbsp; &nbsp; bit0 <br> <br>/* PPROG bit definitions 0x3B */ <br>#define ODD&nbsp; &nbsp; bit7 <br>#define EVEN&nbsp; &nbsp; bit6 <br>#define ELAT&nbsp; &nbsp; bit5&nbsp; &nbsp; /* MC68HC711E9 only */ <br>#define BYTE&nbsp; &nbsp; bit4 <br>#define ROW&nbsp; &nbsp; bit3 <br>#define ERASE&nbsp; bit2 <br>#define EELAT&nbsp; bit1 <br>#define EEPGM&nbsp; bit0 <br>#define EPGM&nbsp; &nbsp; bit0 <br> <br>/* HPRIO bit definitions 0x3C */ <br>#define RBOOT&nbsp; bit7 <br>#define SMOD&nbsp; &nbsp; bit6 <br>#define MDA&nbsp; &nbsp; bit5 <br>#define IRVNE&nbsp; bit4 <br>#define PSEL3&nbsp; bit3 <br>#define PSEL2&nbsp; bit2 <br>#define PSEL1&nbsp; bit1 <br>#define PSEL0&nbsp; bit0 <br> <br>/* INIT&nbsp; bit definitions 0x3D */ <br>#define RAM3&nbsp; &nbsp; bit7 <br>#define RAM2&nbsp; &nbsp; bit6 <br>#define RAM1&nbsp; &nbsp; bit5 <br>#define RAM0&nbsp; &nbsp; bit4 <br>#define REG3&nbsp; &nbsp; bit3 <br>#define REG2&nbsp; &nbsp; bit2 <br>#define REG1&nbsp; &nbsp; bit1 <br>#define REG0&nbsp; &nbsp; bit0 <br> <br>/* TEST1 bit definitions 0x3E */ <br>#define TILOP&nbsp; bit7 <br>#define OCCR&nbsp; &nbsp; bit5 <br>#define CBYP&nbsp; &nbsp; bit4 <br>#define DISR&nbsp; &nbsp; bit3 <br>#define FCM&nbsp; &nbsp; bit2 <br>#define FCOP&nbsp; &nbsp; bit1 <br>#define TCON&nbsp; &nbsp; bit0 <br> <br>/* CONFIG bit definitions 0x3F */ <br>#define EE3&nbsp; &nbsp; bit7&nbsp; &nbsp; /* MC68HC811E2 only */ <br>#define EE2&nbsp; &nbsp; bit6&nbsp; &nbsp; /* MC68HC811E2 only */ <br>#define EE1&nbsp; &nbsp; bit5&nbsp; &nbsp; /* MC68HC811E2 only */ <br>#define EE0&nbsp; &nbsp; bit4&nbsp; &nbsp; /* MC68HC811E2 only */ <br>#define NOSEC&nbsp; bit3 <br>#define NOCOP&nbsp; bit2 <br>#define ROMON&nbsp; bit1&nbsp; &nbsp; /* MC68HC11E9 and MC68HC11E8 only */ <br>#define EPON&nbsp; &nbsp; bit1&nbsp; &nbsp; /* MC68HC711E9 only */ <br>#define EEON&nbsp; &nbsp; bit0 <br> <br><br> <br><br> </td></tr></tbody></table><script language="javascript">postamble();</script> </body></html>