Experiment 3 3-1 Fall 2004
EE583 J E Lumpp
To gain experience with the IASM12 assembler.
To gain experience with the D-Bug12 commands on the M68EVB912B32 Evaluation boards to download S-record files.
CPU12 Reference Manual, Sections 2, 3, 5, App. A
M68EVB912B32 Evaluation Board Users Manual
Course Text, Chapters 1-5
In this experiment you will be assembling HC12 programs and downloading them to the
M68EVB912B32 Evaluation boards. You will also experiment with basic hardware interfacing on the port pins of the HC12 and with basic character I/O routines via the serial port.
1. Assemble the following code using IASM12 (a copy of this code can be found on the course web site).
;**********************************************************************
; A simple demonstration program to see the HC12 run.
; It generates 60 1-second, active-low, pulses on PP0.
; MCU: 68HC912B32EVB, E=8MHz
; Monitor: D-Bug12
;
; 11/4/99 Todd Morton
;**********************************************************************
; Equates
;**********************************************************************
DDRP equ $57
PORTP equ $56
BIT0 equ %00000001
TC1MS equ 1996 ;Delay count for 1ms
;**********************************************************************
; Program
;**********************************************************************
org $0800 main bset PORTP,BIT0 ;Initialize PORTP, BIT0
bset DDRP,BIT0
movb InitCnt,CurCnt ;Initialize pulse counter
;**********************************************************************
; Main loop for output pulse generation
;********************************************************************** pulse bclr PORTP,BIT0 ;Turn pulse on.
ldd #250 ;Wait 250mS
jsr WaitDmS
bset PORTP,BIT0 ;Turn pulse off.
Experiment 3 3-2 Fall 2004
EE583 J E Lumpp
ldd #750 ;Wait 750ms
jsr WaitDmS
dec CurCnt ;Count pulses?
bne pulse ; No: Another pulse
swi ; Yes: Return to monitor
;**********************************************************************
; Subroutine WaitDmS - A programmable delay in mS.
; Arguments: The number of mS is passed in ACCD.
; Registers: preserves all registers except CCR.
; Stack Reqs: 6 bytes stack space
; Req. Subs: Dly1ms
;**********************************************************************
WaitDmS pshd ;preserve ACCD msdlp jsr Dly1ms ;execute 1mS ACCD times
subd #1
bne msdlp
puld ;recover ACCD
rts
;**********************************************************************
; Subroutine Dly1ms - 1ms delay loop.
; MCU: 68HC12, E=8MHz, no clock streching, 16-bit bus
; Registers: preserves all registers except CCR.
; Stack Reqs: 2 bytes stack space
;**********************************************************************
Dly1ms pshx ;preserve IX
ldx #TC1MS ;execute loop TC1MS times d1mslp dex
bne d1mslp
pulx ;recover IX
rts
;**********************************************************************
; Constants
;**********************************************************************
InitCnt fcb 60 ;Initial pulse count
;**********************************************************************
; Variables
;**********************************************************************
CurCnt rmb 1 ;LED flash counter
;**********************************************************************
2. Run this program on the EVB board and verify its operation.
3. Modify the original program so that it will continuously outputs pulses when bit 1 on
PORTP is held high and output no pulses if bit 1 on PRORTP is low. Demonstrate the operation of this program to the instructor.
4. Modify the original program so that it prompts the user via the serial port for the duty cycle of the pulse train to output (1-99%). Then have the program execute 100 pulses at the desired duty cycle at approximately a 2ms period. Demonstrate this program for the instructor.