/* **********tut.c***************** Simulator tutorial program for the MC68HC11EVB This example accompanies the book "Embedded Microcomputer Systems: Real Time Interfacing", Brooks-Cole, copyright (c) 2000, Jonathan W. Valvano 7/6/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 Port C,D are inputs, Port B are outputs Think about where/how a computer stores information 1) I/O ports are windows to external circuits, E.g., PORTD, PORTB, PORTC 2) Registers are very high speed storage, E.g., RegA, RegB, RegY 3) Global memory can be shared, E.g., Dvar, Bvar, Cvar staa Dvar 4) Local variables are allocated at run time and saved on the stack tsx stab 1,x 5) Input devices like switches have binary states on(pushed), off(released) 6) Output devices like LED's have binary states on(light), off(dark) */ #include "HC11.h" unsigned char Dvar,Bvar,Cvar; /* global variables */ unsigned int time; void main(void){ unsigned char theD,theB,theC; /* local variables */ DDRC=0x00; /* PortC are inputs, PortB is output (fixed)*/ DDRD=0x00; /* PortD are inputs */ while(1){ Cvar=PORTC; /* read input, save in global */ theC=PORTC; /* read input, save in local */ Dvar=PORTD; /* read input, save in global */ theD=PORTD; /* read input, save in local */ theB=theD|theC; Bvar=theB; PORTB=theB; /* output */ time=TCNT; /* TCNT is incremented automatically at 2Mhz */ }}; 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 */ }