Enel3dsh1 Lab4
Enel3dsh1 Lab4
INTRODUCTION
This practical provides an opportunity to experiment further with a simple 8515-based microcontroller
system. In this lab you will use Timer 1 in CTC mode and the USART to transmit data to a PC. The PC
will run a serial terminal application such as HyperTerminal and display the data sent via the AVR
USART. Each group will be supplied with an 8515 microcontroller board consisting of a microcontroller
and a virtual serial port over a USB (FT232RL-based) connection to the PC.
PREPARATION REQUIRED.
1. Familiarize yourself with the 8515 microcontroller system, assembly language programming and
the AVR instruction set details. You should be able to answer any questions posed by the lab
demonstrator relating to these aspects.
2. Familiarize yourself with the system connections in preparation for writing the required program for
a digital clock. You should be able to answer any questions posed by the lab demonstrator relating
to these aspects.
3. Complete the section UpdateDigits that updates the ASCII clock digits “HH:MM:SS”. The
subroutine will be marked by the demonstrator. More marks will be given if you avoid doing a
division.
NB: A significant amount of preparation is required to complete this practical in the time available. This
preparation cannot be done satisfactorily by the average person in a single evening. The complete
code should be written before coming in for the practical.
Deploy the above alarm clock. You are expected to research how to configure HyperTerminal to
connect with your USART. Display the time and show that it updates all digits correctly. Show the
following.
After HH:MM:59 - SS clears and MM is incremented
After HH:59:59 - MM and SS clears and HH is incremented
After 23:59:59 - we return to 00:00:00
The less significant hour digit is interesting as it runs from 0 to 9 when the more significant hour digit is
0 or 1. But it runs from 0 to 3 when the more significant hour digit is 2. Show that this works.
Having completed the above, you should add more features to the code. Such as: typing ‘H’ in
HyperTerminal increments the hours, and typing ‘M’ increments the minutes. This will require a simple
receive routine.
1
/*
* EL3DS4lab.asm
* Created: 2012/04/19 09:33:05 AM
* Author: bnaido
*/
.include "m8515def.inc"
.include "Mymacros.asm"
.dseg
.org 0x090
DisplayBuf: .byte 9 ;reserve 9 bytes to store "HH:MM:SS" + carriage return
.cseg
.org 0x0020
Reset:
;***setup the stack***
ldio SPH,high(RAMEND),temp
ldio SPL,low(RAMEND),temp
2
sei ;enable the interrupt subsystem
;The clock tick ISR increments the count on Port C once per second
ClocktickISR:
rcall UpdateDigits
ldi TXcharCount,9 ;prepare to transmit 8 charaters + CR
ld temp,X+ ;start transmission of time string
out UDR,temp
dec TXcharCount
reti
UpdateDigits:
;Recalculate the values for HH:MM:SS after every second. The display is in 24hr format
;rewind the pointer to the DSEG table DisplayBuf
;Convert the numeric values to their ASCII symbols by adding $30
;Store the converted values to the DSEG table. (The Macro StoreNUM2ASC may help!!!)
;the table now contains H,H,:,M,M,:,S,S,13 - 9 ASCII values where 13 in the carriage
;return value. This returns the cursor to the original position so the next time string can
;overwrite the previous one and the clock stays in the same place on the screen.
ret