summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2025-02-05 13:10:17 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2025-02-05 13:10:17 -0500
commitbdb2965d02e8e8fa8f1fdf00e27718f6b048fb06 (patch)
tree43e94e71236fda7ba0d958cd8c28695325dfcebe
parentdab0e17cf2d1b2a1da9493235c571a9821ee8f97 (diff)
Final Changes
-rw-r--r--cmpen472hw3McDonnell/Full_Chip_Simulation.ini2
-rw-r--r--cmpen472hw3McDonnell/Sources/cmpen472hw3_McDonnell.asm173
-rw-r--r--cmpen472hw3McDonnell/Sources/main.asm19
-rw-r--r--cmpen472hw3McDonnell/bin/Project.absbin3358 -> 3358 bytes
-rw-r--r--cmpen472hw3McDonnell/bin/Project.abs.s194
-rw-r--r--cmpen472hw3McDonnell/bin/main.dbg82
-rw-r--r--cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.obin3358 -> 3358 bytes
-rw-r--r--cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx4
-rw-r--r--cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdtbin62658 -> 62658 bytes
9 files changed, 257 insertions, 27 deletions
diff --git a/cmpen472hw3McDonnell/Full_Chip_Simulation.ini b/cmpen472hw3McDonnell/Full_Chip_Simulation.ini
index 9f0ca55..b6a9c64 100644
--- a/cmpen472hw3McDonnell/Full_Chip_Simulation.ini
+++ b/cmpen472hw3McDonnell/Full_Chip_Simulation.ini
@@ -10,7 +10,7 @@ Target=sim
Layout=Full_Chip_Simulation.hwl
LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD
CPU=HC12
-MainFrame=0,1,-1,-1,-1,-1,514,197,1729,1220
+MainFrame=2,3,-1,-1,-1,-1,985,223,2200,1246
Configuration=Full_Chip_Simulation.hwc
Statusbar=1
ShowToolbar=1
diff --git a/cmpen472hw3McDonnell/Sources/cmpen472hw3_McDonnell.asm b/cmpen472hw3McDonnell/Sources/cmpen472hw3_McDonnell.asm
new file mode 100644
index 0000000..2eb72c3
--- /dev/null
+++ b/cmpen472hw3McDonnell/Sources/cmpen472hw3_McDonnell.asm
@@ -0,0 +1,173 @@
+**************************************************************************
+*
+* Title: LED Light Dimmer
+*
+* Objective: CMPEN 472 Homework 3
+*
+* Revision: V1.0
+*
+* Date: Feb. 5, 2025
+*
+* Programmer: Jacob McDonnell
+*
+* Company: The Pennsylvania State University
+* Department of Computer Science and Engineering
+*
+* Algorithm: Simple Parallel I/O use and time delay-loop demo
+*
+* Register Use: A: LED Light on/off state and Switch 1 on/off state
+* X: Delay loop counter
+*
+* Memory Use: RAM Locations from $3000 for data,
+* RAM Locations from $3100 for program
+*
+* Input: Parameters hard-coded in the program - PORTB
+* Switch 1 at PORTB bit 0
+* Switch 2 at PORTB bit 1
+* Switch 3 at PORTB bit 2
+* Switch 4 at PORTB bit 3
+*
+* Output: LED 1 at PORTB bit 4
+* LED 2 at PORTB bit 5
+* LED 3 at PORTB bit 6
+* LED 4 at PORTB bit 7
+*
+* Observation: This program will dim the LED4 to either 5% when the
+* switch is not pressed and 15% when the switch is pressed.
+*
+* Note: ON CSM-12C128 board,
+* Switch 1 is at PORTB bit 0, and
+* LED 4 is at PORTB bit 7.
+*
+* Comments: This program is developed and simulated using CodeWarrior
+* development software and targeted for Axion
+* Manufacturing's CSM-12C128 board running at 24MHz.
+*
+**************************************************************************
+* Parameter Declearation Section
+*
+* Export Symbols
+ xdef pgstart ; export 'pgstart' symbol
+ absentry pgstart ; for assembly entry point
+
+* Symbols and Macros
+PORTA equ $0000 ; i/o port A addresses
+DDRA equ $0002 ; data direction register for PORTA
+PORTB equ $0001 ; i/o port B addresses
+DDRB equ $0003 ; data direction register for PORTB
+
+**************************************************************************
+* Data Section: address used [ $3000 to $30FF ] RAM Memory
+*
+ org $3000 ; Reserved RAM memory starting address
+ ; for Data for CMPEN 472 class
+Counter dc.w $0039 ; X register count number for time Delay
+ ; loop for 10 useconds
+ ; The work to calculate this number is in
+ ; the comments for the delay10usec subroutine.
+
+ONN dc.b $0005 ; Counter for how long LED should be on for
+
+OFF dc.b $005f ; Counter for how long LED should be off for
+
+*
+**************************************************************************
+* Program Section: address used [ $3100 to $3FFF ] RAM Memory
+*
+ org $3100 ; Program start address, in RAM
+pgstart lds #$3100 ; initialize the stack pointer
+
+ ldaa #%11110001 ; LED 1,2,3,4 at PORTB bit 4,5,6,7
+ staa DDRB ; set PORTB bit 4,5,6,7 as output
+
+
+ ldaa #%01010000
+ staa PORTB ; Turn on only LEDs 1 & 3 on PORTB
+
+mainLoop
+ ldaa PORTB ; check bit 0 of PORTB, switch 1
+ anda #%00000001 ; if 0, run blink LED4 5% light level
+ bne p25LED4 ; if 1, run blink LED4 25% light level
+
+p05LED4
+ ldaa #5 ; load 5 into accumulator A
+ staa ONN ; store A in counter ONN
+ ldaa #95 ; load 95 into accumulator A
+ staa OFF ; store A in counter OFF
+ jsr dimmer ; jump to dimmer subroutine
+ bra mainLoop ; loop to mainLoop to check switch
+
+p25LED4
+ ldaa #25 ; load 25 into accumulator A
+ staa ONN ; store A in counter ONN
+ ldaa #75 ; load 75 into accumulator A
+ staa OFF ; store A in counter OFF
+ jsr dimmer ; jump to dimmer subroutine
+ bra mainLoop ; loop to mainLoop to check switch
+
+**************************************************************************
+* Subroutine Section: address used [ $3100 to $3FFF ] RAM Memory
+*
+
+;*************************************************************************
+; dimmer subroutine
+;
+; This subroutine will dim LED4 to a given level
+;
+; Input: Two 1 byte counters, ONN and OFF, for how many times
+; LED4 should be on and off for.
+; Output: LED4 dimmed to a given level, wasted cycles
+; Registers in use: A accumulator to counter number of times looped
+; Memory locations in use: Two bytes ONN and OFF used to dim the LED4 to a given level
+;
+; Comments: This subroutine requires delay10usec subroutine
+;
+
+dimmer
+ bset PORTB,%10000000 ; Turn LED4 on
+ psha ; Save A to the stack
+onDelay ldaa ONN ; Load counter ONN into A
+ beq skipToOff ; if zero jump to loop2 for off
+ jsr delay10usec ; delay for 10 microseconds
+ dec ONN ; decrement counter ONN by 1
+ bra onDelay ; jump back to loop1 always
+skipToOff bclr PORTB,%10000000 ; Turn off LED4
+offDelay ldaa OFF ; load counter OFF into A
+ beq doneLoop ; if 0, skip loop
+ jsr delay10usec ; delay 10 microseconds
+ dec OFF ; decrement counter OFF by 1
+ bra offDelay ; jump back to loop2 always
+doneLoop pula ; restore A from the stack
+ rts ; return to caller
+
+;*************************************************************************
+; delay10usec subroutine
+;
+; This subroutine causes a 10 usec. delay
+;
+; Input: a 16bit count number in 'Counter'
+; Output: time delay, cpu cycle wasted
+; Registers in use: X register, as counter
+; Memory locations in use: a 16bit input number at 'Counter'
+;
+; Comments: Code relies on counter being $39 to be exactly 10 usec work is below
+; Given: freq = 24MHz = 24000000 sec = 10 usec = 0.00001
+; freq = cycles / seconds
+;
+; cycles = freq * seconds = 24000000Hz * 0.00001 = 240
+;
+; This sub routine is 12 + 4 * 'Counter' cycles long, solving for 'Counter'
+; the result is found to be 57.
+;
+
+delay10usec
+ pshx ; Save register x to the stack
+ ldx Counter ; load counter into register x
+innerLoop dex ; decrement register x by 1
+ bne innerLoop ; loop while register x is not 0
+ pulx ; restore register x from the stack
+ nop ; extra nop to make exactly 10 usec
+ rts ; return to caller
+
+ end ; last line of the file
+
diff --git a/cmpen472hw3McDonnell/Sources/main.asm b/cmpen472hw3McDonnell/Sources/main.asm
index a7b67f7..2eb72c3 100644
--- a/cmpen472hw3McDonnell/Sources/main.asm
+++ b/cmpen472hw3McDonnell/Sources/main.asm
@@ -69,6 +69,7 @@ Counter dc.w $0039 ; X register count number for time Delay
ONN dc.b $0005 ; Counter for how long LED should be on for
OFF dc.b $005f ; Counter for how long LED should be off for
+
*
**************************************************************************
* Program Section: address used [ $3100 to $3FFF ] RAM Memory
@@ -80,13 +81,13 @@ pgstart lds #$3100 ; initialize the stack pointer
staa DDRB ; set PORTB bit 4,5,6,7 as output
- ldaa #%00000000
- staa PORTB ; clear all bits of PORTB
+ ldaa #%01010000
+ staa PORTB ; Turn on only LEDs 1 & 3 on PORTB
mainLoop
ldaa PORTB ; check bit 0 of PORTB, switch 1
- anda #%00000001 ; if 0, run blinkLED4 20% light level
- bne p15LED4 ; if 1, run blinkLED4 80% light level
+ anda #%00000001 ; if 0, run blink LED4 5% light level
+ bne p25LED4 ; if 1, run blink LED4 25% light level
p05LED4
ldaa #5 ; load 5 into accumulator A
@@ -96,10 +97,10 @@ p05LED4
jsr dimmer ; jump to dimmer subroutine
bra mainLoop ; loop to mainLoop to check switch
-p15LED4
- ldaa #15 ; load 15 into accumulator A
+p25LED4
+ ldaa #25 ; load 25 into accumulator A
staa ONN ; store A in counter ONN
- ldaa #85 ; load 85 into accumulator A
+ ldaa #75 ; load 75 into accumulator A
staa OFF ; store A in counter OFF
jsr dimmer ; jump to dimmer subroutine
bra mainLoop ; loop to mainLoop to check switch
@@ -132,11 +133,11 @@ onDelay ldaa ONN ; Load counter ONN into A
bra onDelay ; jump back to loop1 always
skipToOff bclr PORTB,%10000000 ; Turn off LED4
offDelay ldaa OFF ; load counter OFF into A
- beq doneRunner ; if 0, skip loop
+ beq doneLoop ; if 0, skip loop
jsr delay10usec ; delay 10 microseconds
dec OFF ; decrement counter OFF by 1
bra offDelay ; jump back to loop2 always
-doneRunner pula ; restore A from the stack
+doneLoop pula ; restore A from the stack
rts ; return to caller
;*************************************************************************
diff --git a/cmpen472hw3McDonnell/bin/Project.abs b/cmpen472hw3McDonnell/bin/Project.abs
index 057d92f..f7ee3e7 100644
--- a/cmpen472hw3McDonnell/bin/Project.abs
+++ b/cmpen472hw3McDonnell/bin/Project.abs
Binary files differ
diff --git a/cmpen472hw3McDonnell/bin/Project.abs.s19 b/cmpen472hw3McDonnell/bin/Project.abs.s19
index aec3e53..eb47c25 100644
--- a/cmpen472hw3McDonnell/bin/Project.abs.s19
+++ b/cmpen472hw3McDonnell/bin/Project.abs.s19
@@ -1,6 +1,6 @@
S0570000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C62696E5C50726F6A6563742E616273AD
S10730000039055F2B
-S1233100CF310086F15A0386005A0196018401260F86057A3002865F7A300316312F20EB5B
-S1233120860F7A300286557A300316312F20DC4C018036B63002270816315273300220F3E5
+S1233100CF310086F15A0386505A0196018401260F86057A3002865F7A300316312F20EB0B
+S123312086197A3002864B7A300316312F20DC4C018036B63002270816315273300220F3E5
S11F31404D0180B63003270816315273300320F3323D34FE30000926FD30A73D26
S9030000FC
diff --git a/cmpen472hw3McDonnell/bin/main.dbg b/cmpen472hw3McDonnell/bin/main.dbg
index 9ea0717..d539dad 100644
--- a/cmpen472hw3McDonnell/bin/main.dbg
+++ b/cmpen472hw3McDonnell/bin/main.dbg
@@ -1,4 +1,49 @@
**************************************************************************
+*
+* Title: LED Light Dimmer
+*
+* Objective: CMPEN 472 Homework 3
+*
+* Revision: V1.0
+*
+* Date: Feb. 5, 2025
+*
+* Programmer: Jacob McDonnell
+*
+* Company: The Pennsylvania State University
+* Department of Computer Science and Engineering
+*
+* Algorithm: Simple Parallel I/O use and time delay-loop demo
+*
+* Register Use: A: LED Light on/off state and Switch 1 on/off state
+* X: Delay loop counter
+*
+* Memory Use: RAM Locations from $3000 for data,
+* RAM Locations from $3100 for program
+*
+* Input: Parameters hard-coded in the program - PORTB
+* Switch 1 at PORTB bit 0
+* Switch 2 at PORTB bit 1
+* Switch 3 at PORTB bit 2
+* Switch 4 at PORTB bit 3
+*
+* Output: LED 1 at PORTB bit 4
+* LED 2 at PORTB bit 5
+* LED 3 at PORTB bit 6
+* LED 4 at PORTB bit 7
+*
+* Observation: This program will dim the LED4 to either 5% when the
+* switch is not pressed and 15% when the switch is pressed.
+*
+* Note: ON CSM-12C128 board,
+* Switch 1 is at PORTB bit 0, and
+* LED 4 is at PORTB bit 7.
+*
+* Comments: This program is developed and simulated using CodeWarrior
+* development software and targeted for Axion
+* Manufacturing's CSM-12C128 board running at 24MHz.
+*
+**************************************************************************
* Parameter Declearation Section
*
* Export Symbols
@@ -18,9 +63,13 @@ DDRB equ $0003 ; data direction register for PORTB
; for Data for CMPEN 472 class
Counter dc.w $0039 ; X register count number for time Delay
; loop for 10 useconds
+ ; The work to calculate this number is in
+ ; the comments for the delay10usec subroutine.
+
ONN dc.b $0005 ; Counter for how long LED should be on for
OFF dc.b $005f ; Counter for how long LED should be off for
+
*
**************************************************************************
* Program Section: address used [ $3100 to $3FFF ] RAM Memory
@@ -32,13 +81,13 @@ pgstart lds #$3100 ; initialize the stack pointer
staa DDRB ; set PORTB bit 4,5,6,7 as output
- ldaa #%00000000
+ ldaa #%01010000
staa PORTB ; clear all bits of PORTB
mainLoop
ldaa PORTB ; check bit 0 of PORTB, switch 1
- anda #%00000001 ; if 0, run blinkLED4 20% light level
- bne p15LED4 ; if 1, run blinkLED4 80% light level
+ anda #%00000001 ; if 0, run blink LED4 5% light level
+ bne p25LED4 ; if 1, run blink LED4 25% light level
p05LED4
ldaa #5 ; load 5 into accumulator A
@@ -48,10 +97,10 @@ p05LED4
jsr dimmer ; jump to dimmer subroutine
bra mainLoop ; loop to mainLoop to check switch
-p15LED4
- ldaa #15 ; load 15 into accumulator A
+p25LED4
+ ldaa #25 ; load 25 into accumulator A
staa ONN ; store A in counter ONN
- ldaa #85 ; load 85 into accumulator A
+ ldaa #75 ; load 75 into accumulator A
staa OFF ; store A in counter OFF
jsr dimmer ; jump to dimmer subroutine
bra mainLoop ; loop to mainLoop to check switch
@@ -77,18 +126,18 @@ p15LED4
dimmer
bset PORTB,%10000000 ; Turn LED4 on
psha ; Save A to the stack
-loop1 ldaa ONN ; Load counter ONN into A
+onDelay ldaa ONN ; Load counter ONN into A
beq skipToOff ; if zero jump to loop2 for off
jsr delay10usec ; delay for 10 microseconds
dec ONN ; decrement counter ONN by 1
- bra loop1 ; jump back to loop1 always
+ bra onDelay ; jump back to loop1 always
skipToOff bclr PORTB,%10000000 ; Turn off LED4
-loop2 ldaa OFF ; load counter OFF into A
- beq doneRunner ; if 0, skip loop
+offDelay ldaa OFF ; load counter OFF into A
+ beq doneLoop ; if 0, skip loop
jsr delay10usec ; delay 10 microseconds
dec OFF ; decrement counter OFF by 1
- bra loop2 ; jump back to loop2 always
-doneRunner pula ; restore A from the stack
+ bra offDelay ; jump back to loop2 always
+doneLoop pula ; restore A from the stack
rts ; return to caller
;*************************************************************************
@@ -101,7 +150,14 @@ doneRunner pula ; restore A from the stack
; Registers in use: X register, as counter
; Memory locations in use: a 16bit input number at 'Counter'
;
-; Comments: Code relies on counter being $39 to be exactly 10 usec
+; Comments: Code relies on counter being $39 to be exactly 10 usec work is below
+; Given: freq = 24MHz = 24000000 sec = 10 usec = 0.00001
+; freq = cycles / seconds
+;
+; cycles = freq * seconds = 24000000Hz * 0.00001 = 240
+;
+; This sub routine is 12 + 4 * 'Counter' cycles long, solving for 'Counter'
+; the result is found to be 57.
;
delay10usec
diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o
index 057d92f..f7ee3e7 100644
--- a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o
+++ b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.o
Binary files differ
diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx
index ffb691f..69819b7 100644
--- a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx
+++ b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/ObjectCode/main.asm.sx
@@ -1,6 +1,6 @@
S0820000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877334D63446F6E6E656C6C5C636D70656E3437326877334D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D93
S10730000039055F2B
-S1233100CF310086F15A0386005A0196018401260F86057A3002865F7A300316312F20EB5B
-S1233120860F7A300286557A300316312F20DC4C018036B63002270816315273300220F3E5
+S1233100CF310086F15A0386505A0196018401260F86057A3002865F7A300316312F20EB0B
+S123312086197A3002864B7A300316312F20DC4C018036B63002270816315273300220F3E5
S11F31404D0180B63003270816315273300320F3323D34FE30000926FD30A73D26
S9033100CB
diff --git a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt
index a198002..c40ecdc 100644
--- a/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt
+++ b/cmpen472hw3McDonnell/cmpen472hw3McDonnell_Data/Standard/TargetDataWindows.tdt
Binary files differ