EE 5340/7340 Biomedical Instrumentation Laboratory 6:

Use of the 68HC11 A/D Converter and Timer

 

Our goals in this lab are to familiarize ourselves with the Motorola 68HC11 microcontroller interrupts, timer, and A/D converter. We want to be able to write a program that samples an analog signal at a fixed sampling rate. For this, we will use the timer and the A/D converter located on the 68HC11.

 

  1. To get the big picture of what we will need to know for this lab, check out the following slides.
  2. There is a lot of material regarding interrupts, the timer, and the A/D converter. The slides above have isolated only those portions of the 68HC11 reference manual that you will need to read. Read the pertinent sections from the 68HC11 reference manual to find out the address of the various registers, etc.
  3. You can use either interrupts or “polling” to do your A/D conversions at regular sampling intervals. The following program uses interrupts and illustrates how to program the timer in order to generate timer overflow interrupts. Also, when you have your program working, you will need to reprogram the timer in order to sample the EKG at a more realistic sampling rate (at least twice the highest frequency in the EKG to avoid aliasing). Run the above program and describe in your writeup what the program is doing and what you observe in the BUFALO monitor.
  4. The timer counting rate is determined by the two least significant bits in the TMSK2 register of the timer. These bits determine the rate at which the timer overflows and hence, the sampling rate. They can only be programmed within the first 64 clock cycles after RESET. Therefore, the desired rate at which the character “A” is sent to the monitor in step 3 above is not the desired rate of about 2 characters per second. In order to correctly program the TMSK2 register, it is necessary to write the program to the EEPROM chip whose address begins at $E000. This can be done by carefully following the instructions in the latter half of the tutorial in the CME11E9-EVBU manual. One thing that is not entirely clear from reading the manuals is that the BUFALO monitor uses one set of interrupt vectors (see page 223 of the CME11E9-EVBU manual) but when the chip is running a program without the monitor, the interrupt vectors are at different locations (see page 131 of the the 68HC11 reference manual). Also, the BUFALO monitor uses JMP instructions in the interrupt vector, while the actual processor just has the addresses in the interrupt vectors. So before programming the EEPROM with the program, you will have to uncomment the interrupt vectors used by the microcontroller as well as the starting address of the program ($E000). Be sure that the ROMON is disabled when programming the EEPROM, to go back to the BUFALO monitor, ROMON should be enabled. Also don’t forget to remove the two jumpers JP1 and JP2 (mode select jumpers) as indicated in the CME11E9-EVBU tutorial. Indicate in your write up how the program behavior changes after running it from the EEPROM.
  5. At this point, you should be ready to write your program for sampling the EKG. I recommend you use a DC power supply as the signal source to debug your sampling program. Try sampling the DC supply once every half second or so and then transmit the sample to the BUFALO monitor via the serial port (using the program from the previous lab). Include a copy of the monitor window in your writeup showing the different voltage values (which are manifested here as ASCII characters). Following are addresses of different registers for the A/D converter:

·        OPTION: $1039 (the ADPU bit must be set to 1 by the programmer to provide power to the A/D converter).

·        ADCTL: $1030 (see 68HC11 reference manual, p. 12-15).

·        ADR1: $1031

·        ADR2: $1032

·        ADR3: $1033

·        ADR4: $1034