summaryrefslogtreecommitdiff
path: root/cmpen472hw10_McDonnell/bin/main.dbg
diff options
context:
space:
mode:
Diffstat (limited to 'cmpen472hw10_McDonnell/bin/main.dbg')
-rw-r--r--cmpen472hw10_McDonnell/bin/main.dbg89
1 files changed, 82 insertions, 7 deletions
diff --git a/cmpen472hw10_McDonnell/bin/main.dbg b/cmpen472hw10_McDonnell/bin/main.dbg
index d635a34..26d5a48 100644
--- a/cmpen472hw10_McDonnell/bin/main.dbg
+++ b/cmpen472hw10_McDonnell/bin/main.dbg
@@ -1,19 +1,20 @@
**************************************************************************
*
-* Title: Calculator Clock
+* Title: Signal Generator
*
-* Objective: CMPEN 472 Homework 9
+* Objective: CMPEN 472 Homework 10
*
* Revision: V1.0
*
-* Date: Apr. 2, 2025
+* Date: Apr. 11, 2025
*
* Programmer: Jacob McDonnell
*
* Company: The Pennsylvania State University
* Department of Computer Science and Engineering
*
-* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking
+* Algorithm: Simple Serial I/O, Real Time Interrupts for Time Tracking, and
+* output compare timer for generating functions.
*
* Register Use: A & B to current byte, etc,
* X & Y holds address of strings and length of string,
@@ -248,6 +249,20 @@ rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag
rtidone jsr PrintTime ; Jump to PrintTime
rtiSkip RTI ; Return from RTI ISR
+;*************************************************************************
+; oc5isr subroutine
+;
+; This subroutine will set a flag after a set number of cycles.
+;
+; Input: interval memory location for the number of cycles between triggers
+; Output: The outputCnt counting the number of triggers, and timeTrigger to
+; signal a timmer trigger.
+; Registers in use: A for setting timeTrigger, D for increasing outputCnt and setting next count.
+; Memory locations in use: Memory Address for oc5 timer, outputCnt, timeTrigger, numPoints, interval
+;
+; Comments: The timer will stop after outputCnt == numPoints
+;
+
oc5isr ldd interval ; Load the interval for the next clock cycle
addd TC5H ; for next interrupt
std TC5H ;
@@ -262,6 +277,23 @@ oc5isr ldd interval ; Load the interval for the next clock c
jsr StopTimerCH5 ; Stop Channel 5 Timer
oc5Done RTI ; Return from interrupt
+;*************************************************************************
+; PrintWave subroutine
+;
+; This subroutine will print a one byte decimal value to the serial console.
+; The outputVal will be incremented by increment. It can follow a square wave,
+; a triangle wave, & a sawtooth wave pattern.
+;
+; Input: waveType to denote the patter, increment to increment the outputVal
+; Output: outputVal printed to the serial console
+; Registers in use: A for finding the wave type, B for reading the outputVal,
+; D for math and checking of outputVal
+; Memory locations in use: waveType to set the patter, outputVal for printing
+; the output value
+;
+; Comments: The timer will stop after outputCnt == numPoints
+;
+
PrintWave
pshd ; Save D to the stack
pshy ; Save Y to the stack
@@ -365,6 +397,20 @@ DonePrint stab outputVal ; Store updated output value
puld ; Restore D from the stack
rts ; Return from Caller
+;*************************************************************************
+; StartTimer5oc subroutine
+;
+; This subroutine will enable & start the oc5 timer.
+;
+; Input: Interval to set the next clock cycle
+; Output: No output other
+; Registers in use: A used for setting up the oc5 timer, D for setting the next trigger
+; Memory locations in use: All memory locations used for the oc5 timer.
+; interval to set the next cycle.
+;
+; Comments: The timer will be enabled only on channel 5 for output compare.
+;
+
StartTimer5oc
PSHD
LDAA #%00100000
@@ -375,7 +421,7 @@ StartTimer5oc
LDAA #%00000000 ; TOI Off, TCRE Off, TCLK = BCLK/1
STAA TSCR2 ; not needed if started from reset
- LDD #3000 ; 125usec with (24MHz/1 clock)
+ LDD interval ; 125usec with (24MHz/1 clock)
ADDD TCNTH ; for first interrupt
STD TC5H ;
@@ -385,6 +431,19 @@ StartTimer5oc
PULD
RTS
+;*************************************************************************
+; StopTimerCH5 subroutine
+;
+; This subroutine will stop and disable the timer.
+;
+; Input: No Input
+; Output: No output other
+; Registers in use: A to disable the timer.
+; Memory locations in use: TIE to disable the timer.
+;
+; Comments: The timer will be disabled on all channels.
+;
+
StopTimerCH5
psha ; Save A to the stack
clra ; Clear A
@@ -392,6 +451,23 @@ StopTimerCH5
pula ; Restore A from the stack
rts ; Return
+;*************************************************************************
+; GenWave subroutine
+;
+; This subroutine will setup the proper variables to generate a wave and wait
+; for the wave to finish generating.
+;
+; Input: No input but the variables for PrintWave are required.
+; Output: No output except for the output of PrintWave
+; Registers in use: A for reading the timeTrigger variable,
+; D for reading outputCnt.
+; Memory locations in use: outputCnt, outputVal, timeTrigger, numPoints.
+;
+; Comments: This subroutine does not have any direct input or output but calls
+; PrintWave so the inputs for PrintWave should be set and the output
+; of PrintWave should be expected.
+;
+
GenWave
pshd ; Save D to the stack
ldd #0 ; Clear D
@@ -400,7 +476,6 @@ GenWave
jsr StartTimer5oc ; Start Timer on CH5
-
genLoop ldaa timeTrigger ; Load timeTrigger into A
beq genLoop ; If A == 0, loop
clra ; Clear A
@@ -966,7 +1041,7 @@ getchar7 clra ; Set A to 0
badInput dc.b 'Invalid Input',CR,LF,NULL ; Invalid Input Prompt
; twMsg: welcome message for typewrite
-twMsg dc.b CR,LF,'Clock stopped and Typewrite program started.',CR,LF
+twMsg dc.b 'Wave Generator and Clock stopped and Typewrite program started.',CR,LF
dc.b 'You may type below.',CR,LF,NULL
; Messages for different waveforms