From 2fd1f7292d432684783e021c149e89c275f69334 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Mon, 7 Apr 2025 19:30:15 -0400 Subject: HW10: 8KHz waves working --- cmpen472hw10_McDonnell/Full_Chip_Simulation.ini | 2 +- cmpen472hw10_McDonnell/Sources/example.asm | 356 +++++++++++++++++++++ cmpen472hw10_McDonnell/Sources/main.asm | 180 ++++++++--- cmpen472hw10_McDonnell/bin/Project.abs | Bin 9384 -> 10518 bytes cmpen472hw10_McDonnell/bin/Project.abs.phy | 5 +- cmpen472hw10_McDonnell/bin/Project.abs.s19 | 110 ++++--- cmpen472hw10_McDonnell/bin/main.dbg | 257 +++++++++++---- .../Standard/ObjectCode/main.asm.o | Bin 9384 -> 10518 bytes .../Standard/ObjectCode/main.asm.sx | 110 ++++--- .../Standard/TargetDataWindows.tdt | Bin 64818 -> 66759 bytes .../CWSettingsWindows.stg | Bin 2004 -> 4175 bytes exam2prep/Full_Chip_Simulation.ini | 2 +- .../Standard/TargetDataWindows.tdt | Bin 64906 -> 64906 bytes 13 files changed, 796 insertions(+), 226 deletions(-) create mode 100644 cmpen472hw10_McDonnell/Sources/example.asm diff --git a/cmpen472hw10_McDonnell/Full_Chip_Simulation.ini b/cmpen472hw10_McDonnell/Full_Chip_Simulation.ini index e6799e8..8d019ae 100644 --- a/cmpen472hw10_McDonnell/Full_Chip_Simulation.ini +++ b/cmpen472hw10_McDonnell/Full_Chip_Simulation.ini @@ -10,7 +10,7 @@ Target=sim Layout=ASM_layout.hwl LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD CPU=HC12 -MainFrame=0,1,-1,-1,-1,-1,1150,95,2453,1111 +MainFrame=0,1,-1,-1,-1,-1,234,85,1986,1101 Configuration=Full_Chip_Simulation.hwc Statusbar=1 ShowToolbar=1 diff --git a/cmpen472hw10_McDonnell/Sources/example.asm b/cmpen472hw10_McDonnell/Sources/example.asm new file mode 100644 index 0000000..0ab912d --- /dev/null +++ b/cmpen472hw10_McDonnell/Sources/example.asm @@ -0,0 +1,356 @@ +;******************************************************* +;* CMPEN 472, 2022 Spring +;* Homework 10: Timer Interrupt Sample Program, +;* MC9S12C128 Program (set to MC9S12C32 for Simulation/Debug) +;* CodeWarrior Simulator/Debug edition, not for CSM-12C128 board +;* Nov. 01, 2021 Kyusun Choi +;* March 27, 2022 Kyusun Choi +;* Nov. 07, 2022 Kyusun Choi +;* +;* This program is a 1024 data transfer program running on the +;* CodeWarrior Debugger/Simulator as follows: +;* 1. Program starts with print messages on the simulator Terminal, +;* an intro message at 1.5M baud (this program will not work +;* on the CSM-12C128 board - 1.5M baud too fast). +;* 2. Then user may hit any key, it's a typewriter program at 1.5M baud. +;* But hitting the Enter key will terminate the typewriter mode with +;* the instruction message print. +;* 3. Two messages are (1) start terminal data capture into a file and +;* (2) hit Enter key for the 1024 data transfer to begin. +;* 4. At this time, user setup the Terminal Output file, data capture to a file. +;* 5. User hits an Enter key to send 1024 data, to the Terminal and +;* the data saved in to a file named RxData3.txt which may be looked at +;* or plotted using Excel sheet. +;* 6. User may repeat the step 3 above as many times as he/she like. +;* User plots or prints the data to verify the correct data transmit. +;* +;* We assumed 24MHz bus clock and 4MHz external resonator clock frequency. +;* +;******************************************************* +;******************************************************* + +; export symbols - program starting point + XDEF Entry ; export 'Entry' symbol + ABSENTRY Entry ; for assembly entry point + +; include derivative specific macros +PORTB EQU $0001 +DDRB EQU $0003 + +SCIBDH EQU $00C8 ; Serial port (SCI) Baud Register H +SCIBDL EQU $00C9 ; Serial port (SCI) Baud Register L +SCICR2 EQU $00CB ; Serial port (SCI) Control Register 2 +SCISR1 EQU $00CC ; Serial port (SCI) Status Register 1 +SCIDRL EQU $00CF ; Serial port (SCI) Data Register + +TIOS EQU $0040 ; Timer Input Capture (IC) or Output Compare (OC) select +TIE EQU $004C ; Timer interrupt enable register +TCNTH EQU $0044 ; Timer free runing main counter +TSCR1 EQU $0046 ; Timer system control 1 +TSCR2 EQU $004D ; Timer system control 2 +TFLG1 EQU $004E ; Timer interrupt flag 1 +TC6H EQU $005C ; Timer channel 2 register + +CR equ $0d ; carriage return, ASCII 'Return' key +LF equ $0a ; line feed, ASCII 'next line' character + +DATAmax equ 1024 ; Data count maximum, 1024 constant + +;******************************************************* +; variable/data section + ORG $3000 ; RAMStart defined as $3000 + ; in MC9S12C128 chip + +ctr125u DS.W 1 ; 16bit interrupt counter for 125 uSec. of time + +BUF DS.B 6 ; character buffer for a 16bit number in decimal ASCII +CTR DS.B 1 ; character buffer fill count + +msg1 DC.B 'Hello, this is 1024 data transmit program.', $00 +msg2 DC.B 'When ready, hit Enter key.', $00 +;* more text messages at the End of this program + +;******************************************************* +; interrupt vector section + + ORG $FFE2 ; Timer channel 6 interrupt vector setup, on simulator + DC.W oc6isr + +;******************************************************* +; code section + + ORG $3100 +Entry + LDS #Entry ; initialize the stack pointer + + LDAA #%11111111 ; Set PORTB bit 0,1,2,3,4,5,6,7 + STAA DDRB ; as output + LDAA #%00000000 ; Clear PORTB bit 0,1,2,3,4,5,6,7 + STAA PORTB ; Clear all bits of PORTB, initialize + + ldaa #$0C ; Enable SCI port Tx and Rx units + staa SCICR2 ; disable SCI interrupts + + ldd #$0001 ; Set SCI Baud Register = $0001 => 1.5M baud at 24MHz (for simulation) +; ldd #$0002 ; Set SCI Baud Register = $0002 => 750K baud at 24MHz +; ldd #$000D ; Set SCI Baud Register = $000D => 115200 baud at 24MHz +; ldd #$009C ; Set SCI Baud Register = $009C => 9600 baud at 24MHz + std SCIBDH ; SCI port baud rate change + + ldx #msg1 ; print the first message, '1024 data transmit' + jsr printmsg + jsr nextline + + ldx #msg2 ; print the second message, user instruction, + jsr printmsg ; hit 'Enter' + jsr nextline + +mloop1 + jsr getchar + cmpa #0 + beq mloop1 + jsr putchar ; type writer, with echo print + cmpa #CR + bne mloop1 ; if Enter/Return key is pressed, move the + + ldaa #LF ; cursor to next line + jsr putchar + + ldx #msg3 ; print '> Set Terminal save file RxData3.txt' + jsr printmsg + jsr nextline + + ldx #msg4 ; print '> Press Enter/Return key to start sawtooth wave' + jsr printmsg + jsr nextline + + jsr delay1ms ; flush out SCI serial port + ; wait to finish sending last characters + +mloop2 + jsr getchar + cmpa #0 + beq mloop2 + cmpa #CR + bne mloop2 ; if Enter/Return key is pressed, move the + + jsr nextline + jsr nextline + jsr delay1ms ; flush out SCI serial port + ; wait to finish sending last characters + + ldx #0 ; Enter/Return key hit + stx ctr125u + jsr StartTimer6oc + + CLI ; Interrupt enable, for Timer OC6 interrupt start + + +loop1024 + ldd ctr125u + cpd #DATAmax ; 1024 bytes will be sent, the receiver at Windows PC + bhs loopTxON ; will only take 1024 bytes. + bra loop1024 ; set Terminal Cache Size to 10000 lines, update from 1000 lines + +loopTxON + LDAA #%00000000 + STAA TIE ; disable OC6 interrupt + + jsr nextline + jsr nextline + + ldx #msg5 ; print '> Done! Close Output file.' + jsr printmsg + jsr nextline + + ldx #msg6 ; print '> Ready for next data transmission' + jsr printmsg + jsr nextline + + BRA mloop2 + + +;subroutine section below + +;***********Timer OC6 interrupt service routine*************** +oc6isr + ldd #3000 ; 125usec with (24MHz/1 clock) + addd TC6H ; for next interrupt + std TC6H ; + bset TFLG1,%01000000 ; clear timer CH6 interrupt flag, not needed if fast clear enabled + ldd ctr125u + ldx ctr125u + inx ; update OC6 (125usec) interrupt counter + stx ctr125u + clra ; print ctr125u, only the last byte + jsr pnum10 ; to make the file RxData3.txt with exactly 1024 data +oc2done RTI +;***********end of Timer OC6 interrupt service routine******** + +;***************StartTimer6oc************************ +;* Program: Start the timer interrupt, timer channel 6 output compare +;* Input: Constants - channel 6 output compare, 125usec at 24MHz +;* Output: None, only the timer interrupt +;* Registers modified: D used and CCR modified +;* Algorithm: +; initialize TIOS, TIE, TSCR1, TSCR2, TC2H, and TFLG1 +;********************************************** +StartTimer6oc + PSHD + LDAA #%01000000 + STAA TIOS ; set CH6 Output Compare + STAA TIE ; set CH6 interrupt Enable + LDAA #%10000000 ; enable timer, Fast Flag Clear not set + STAA TSCR1 + LDAA #%00000000 ; TOI Off, TCRE Off, TCLK = BCLK/1 + STAA TSCR2 ; not needed if started from reset + + LDD #3000 ; 125usec with (24MHz/1 clock) + ADDD TCNTH ; for first interrupt + STD TC6H ; + + BSET TFLG1,%01000000 ; initial Timer CH6 interrupt flag Clear, not needed if fast clear set + LDAA #%01000000 + STAA TIE ; set CH6 interrupt Enable + PULD + RTS +;***************end of StartTimer2oc***************** + + +;***********pnum10*************************** +;* Program: print a word (16bit) in decimal to SCI port +;* Input: Register D contains a 16 bit number to print in decimal number +;* Output: decimal number printed on the terminal connected to SCI port +;* +;* Registers modified: CCR +;* Algorithm: +; Keep divide number by 10 and keep the remainders +; Then send it out to SCI port +; Need memory location for counter CTR and buffer BUF(6 byte max) +;********************************************** +pnum10 pshd ;Save registers + pshx + pshy + clr CTR ; clear character count of an 8 bit number + + ldy #BUF +pnum10p1 ldx #10 + idiv + beq pnum10p2 + stab 1,y+ + inc CTR + tfr x,d + bra pnum10p1 + +pnum10p2 stab 1,y+ + inc CTR +;-------------------------------------- + +pnum10p3 ldaa #$30 + adda 1,-y + jsr putchar + dec CTR + bne pnum10p3 + jsr nextline + puly + pulx + puld + rts +;***********end of pnum10******************** + +;***********printmsg*************************** +;* Program: Output character string to SCI port, print message +;* Input: Register X points to ASCII characters in memory +;* Output: message printed on the terminal connected to SCI port +;* +;* Registers modified: CCR +;* Algorithm: +; Pick up 1 byte from memory where X register is pointing +; Send it out to SCI port +; Update X register to point to the next byte +; Repeat until the byte data $00 is encountered +; (String is terminated with NULL=$00) +;********************************************** +NULL equ $00 +printmsg psha ;Save registers + pshx +printmsgloop ldaa 1,X+ ;pick up an ASCII character from string + ; pointed by X register + ;then update the X register to point to + ; the next byte + cmpa #NULL + beq printmsgdone ;end of strint yet? + bsr putchar ;if not, print character and do next + bra printmsgloop +printmsgdone pulx + pula + rts +;***********end of printmsg******************** + +;***************putchar************************ +;* Program: Send one character to SCI port, terminal +;* Input: Accumulator A contains an ASCII character, 8bit +;* Output: Send one character to SCI port, terminal +;* Registers modified: CCR +;* Algorithm: +; Wait for transmit buffer become empty +; Transmit buffer empty is indicated by TDRE bit +; TDRE = 1 : empty - Transmit Data Register Empty, ready to transmit +; TDRE = 0 : not empty, transmission in progress +;********************************************** +putchar brclr SCISR1,#%10000000,putchar ; wait for transmit buffer empty + staa SCIDRL ; send a character + rts +;***************end of putchar***************** + +;****************getchar*********************** +;* Program: Input one character from SCI port (terminal/keyboard) +;* if a character is received, other wise return NULL +;* Input: none +;* Output: Accumulator A containing the received ASCII character +;* if a character is received. +;* Otherwise Accumulator A will contain a NULL character, $00. +;* Registers modified: CCR +;* Algorithm: +; Check for receive buffer become full +; Receive buffer full is indicated by RDRF bit +; RDRF = 1 : full - Receive Data Register Full, 1 byte received +; RDRF = 0 : not full, 0 byte received +;********************************************** + +getchar brclr SCISR1,#%00100000,getchar7 + ldaa SCIDRL + rts +getchar7 clra + rts +;****************end of getchar**************** + +;****************nextline********************** +nextline + psha + ldaa #CR ; move the cursor to beginning of the line + jsr putchar ; Cariage Return/Enter key + ldaa #LF ; move the cursor to next line, Line Feed + jsr putchar + pula + rts +;****************end of nextline*************** + +;****************delay1ms********************** +delay1ms: pshx + ldx #$1000 ; count down X, $8FFF may be more than 10ms +d1msloop nop ; X <= X - 1 + dex ; simple loop + bne d1msloop + pulx + rts +;****************end of delay1ms*************** + +msg3 DC.B '> Be sure to start saving Terminal data: open Output file = RxData3.txt', $00 +msg4 DC.B '> When ready, hit Enter/Return key for sawtooth wave, 1024 point print.', $00 +msg5 DC.B '> Done! You may close the Output file.', $00 +msg6 DC.B '> Ready for next data transmission, hit Enter key.', $00 + + END ; this is end of assembly source file + ; lines below are ignored - not assembled + diff --git a/cmpen472hw10_McDonnell/Sources/main.asm b/cmpen472hw10_McDonnell/Sources/main.asm index 48b407b..5be05f0 100644 --- a/cmpen472hw10_McDonnell/Sources/main.asm +++ b/cmpen472hw10_McDonnell/Sources/main.asm @@ -59,6 +59,14 @@ CRGFLG EQU $0037 ; Clock and Reset Generator Flags CRGINT EQU $0038 ; Clock and Reset Generator Interrupts RTICTL EQU $003B ; Real Time Interrupt Control +TIOS EQU $0040 ; Timer Input Capture (IC) or Output Compare (OC) select +TIE EQU $004C ; Timer interrupt enable register +TCNTH EQU $0044 ; Timer free runing main counter +TSCR1 EQU $0046 ; Timer system control 1 +TSCR2 EQU $004D ; Timer system control 2 +TFLG1 EQU $004E ; Timer interrupt flag 1 +TC5H EQU $005A ; Timer channel 5 register + CR equ $0d ; carriage return, ASCII 'Return' key LF equ $0a ; line feed, ASCII 'next line' character NULL equ $00 ; NULL Terminator character @@ -89,6 +97,7 @@ numBuf dc.b $0000 ; Used by ReadDecimal for reading number operator dc.b $0000 ; Used by ReadDecimal for reading numbers inputBuffer ds.b $0010 ; Input Buffer Length + dc.b NULL lenInput dc.w $0010 ; Length of the Input Buffer @@ -98,9 +107,13 @@ outputVal dc.b $00 ; Used to track the output value of the outputCnt dc.w $0000 ; Used to track how many values have been outputted -interval dc.w $3000 ; Used to set the timer module based on clock cycles +interval dc.w 3000 ; Used to set the timer module based on clock cycles + +numPoints dc.w 2048 ; Max Number of points for waves + +timeTrigger dc.b $00 ; Tracks when timer is triggered -waveType dc.b 'S' ; Used to track wave type 'T' for increasing triangle, +waveType dc.b 'q' ; Used to track wave type 'T' for increasing triangle, ; 't' for decreasing triangle, ; 'Q' for square high ; 'q' for square low @@ -115,10 +128,10 @@ waveType dc.b 'S' ; Used to track wave type 'T' for increa dc.w rtiisr ; Real Time Interrupt vector * ************************************************************************** -* Timer Interrupt Vector Section: address used [ $FFE2 to $FFE3 ] RAM Memory +* Timer Interrupt Vector Section: address used [ $FFE4 to $FFE5 ] RAM Memory * - org $FFE2 ; Timer channel 6 interrupt vector setup, on simulator - dc.w oc6isr + org $FFE4 ; Timer channel 5 interrupt vector setup, on simulator + dc.w oc5isr * ************************************************************************** * Program Section: address used [ $3100 to $3FFF ] RAM Memory @@ -146,34 +159,28 @@ pgstart lds #$3100 ; initialize the stack pointer ldaa #$FF ; Two 7 segment displays on PORTB staa DDRB ; Set all of PORTB as output - ldx #inputBuffer ; Load the address of inputBuffer into X - ldy lenInput ; Load the length of inputBuffer into Y - jsr Zeros ; Zero out inputBuffer cli ; Enable interrupts - jsr PrintTime ; Jump to PrintTime to write to serial console - ldx #spacer ; Load the address of spacer into X - jsr WriteString ; Write the spacer string to the output - jsr PrintPrompt ; Jump to PrintPrompt to write to serial console mainLoop ldx #inputBuffer ; Load the address of inputBuffer into X ldy lenInput ; Load the length of inputBuffer into Y jsr ReadString ; Jump to ReadString to read input - ldx #inputBuffer ; Load the address of inputBuffer into X - jsr ExecuteCommand ; Jump to ExecuteCommand + ldd #0 ; Clear D + std outputCnt ; Clear outputCnt + staa outputVal ; Clear outputVal - ldx #inputBuffer ; Load the address of inputBuffer into X - ldaa 0,x ; Load first character from inputBuffer into A - beq mainLoop ; If A == 0, branch to mainLoop, only zero if Solve was called - ldy lenInput ; Load the length of inputBuffer into Y - jsr Zeros ; Zero out inputBuffer + jsr StartTimer5oc ; Start Timer on CH5 - sei ; Disable interrupts - jsr PrintTime ; Jump to PrintTime to print new time - ldx #spacer ; Load the address of spacer into X - jsr WriteString ; Write the spacer string to the output - jsr PrintPrompt ; Jump to PrintPrompt to write to serial console - cli ; Enable interrupts +looooop ldaa timeTrigger + beq looooop + clra + staa timeTrigger + jsr PrintWave ; Jump to PrintWave + ldd outputCnt + cpd numPoints + blo looooop + + jsr StopTimerCH5 bra mainLoop ; Loop back to mainLoop always @@ -212,6 +219,7 @@ twLoop jsr getchar ; Read a character from the serial conso ; rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + cli ; Enable interrupts ldx counter ; Load counter into X inx ; Increment counter by 1 stx counter ; Save X to counter @@ -243,85 +251,151 @@ rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag rtidone jsr PrintTime ; Jump to PrintTime rtiSkip RTI ; Return from RTI ISR -oc6isr ldd interval ; Load the interval for the next clock cycle - addd TC6H ; for next interrupt - std TC6H ; +oc5isr ldd interval ; Load the interval for the next clock cycle + addd TC5H ; for next interrupt + std TC5H ; + bset TFLG1,%00100000 ; Clear CH5 interrupt flag + ldaa #1 ; Load 1 into A + staa timeTrigger ; Signal that timer went off ldd outputCnt ; Load the count of values outputed into D addd #1 ; Increase output count by 1 std outputCnt ; Update the count of outputted values - cpd #2048 ; Compare D to the max number of values - bne oc6Done ; If D != 2048, exit ISR - ldd #0 ; Clear the D register - std outputCnt ; Reset the count - staa outputVal ; Reset the output value - RTI ; Return from interrupt -oc6Done jsr PrintWave ; Jump to PrintWave - RTI ; Return from interrupt + cpd numPoints ; Compare D to numPoints + blo oc5Done ; If D < numPoints, Done + jsr StopTimerCH5 ; Stop Channel 5 Timer +oc5Done RTI ; Return from interrupt PrintWave pshd ; Save D to the stack + pshy ; Save Y to the stack ldaa waveType ; Load the waveType into A cmpa #'T' ; Compare to 'T' - beq TriangleInc ; If A == 'T', triangle wave increasing + lbeq TriangleInc ; If A == 'T', triangle wave increasing cmpa #'t' ; Compare A to 't' - beq TriangleDec ; If A == 't', triangle wave decreasing + lbeq TriangleDec ; If A == 't', triangle wave decreasing cmpa #'Q' ; Compare A to 'Q' - beq SquareWaveH ; If A == 'Q', square wave high + lbeq SquareWaveH ; If A == 'Q', square wave high cmpa #'q' ; Compare A to 'q' - beq SquareWaveL ; If A == 'q', square wave low + lbeq SquareWaveL ; If A == 'q', square wave low SawToothWav clra ; Clear A ldab outputVal ; Load the output value into B + ldy #buffer ; Load the address of buffer into Y jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack addd #1 ; Increment output value by 1 cpd #256 ; Compare D to 256 - bne DonePrint ; If D != 256, Done + lbne DonePrint ; If D != 256, Done clrb ; Reset to Zero - bra DonePrint ; Branch to DonePrint + lbra DonePrint ; Branch to DonePrint SquareWaveH clra ; Clear A ldab #255 ; Load 255 into B + ldy #buffer ; Load the address of buffer into Y jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack + clra ; Clear A ldab outputVal ; Load the output value into B - addb #1 ; Add 1 to B - cmpb #255 ; Compare B to 255 - bnq DonePrint ; If B != 255, done + addd #1 ; Add 1 to D + cpd #256 ; Compare D to 256 + lbne DonePrint ; If D != 256, done clrb ; Reset B to zero ldaa #'q' ; Load 'q' into A staa waveType ; Update wave type to square wave low bra DonePrint ; Branch to DonePrint SquareWaveL clra ; Clear A clrb ; Reset B to zero + ldy #buffer ; Load the address of buffer into Y jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack + clra ; Clear A ldab outputVal ; Load the output value into B - addb #1 ; Add 1 to B - cmpb #255 ; Compare B to 255 - bnq DonePrint ; If B != 255, done + addd #1 ; Add 1 to D + cpd #256 ; Compare D to 256 + bne DonePrint ; If D != 256, done clrb ; Reset B to zero ldaa #'Q' ; Load 'Q' into A staa waveType ; Update wave type to square wave low bra DonePrint ; Branch to DonePrint TriangleInc clra ; Clear A ldab outputVal ; Load the output value into B + ldy #buffer ; Load the address of buffer into Y jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack addd #1 ; Add 1 to D cpd #256 ; Compare D to 256 bne DonePrint ; If D != 256, done - subd #1 ; Subtract 1 from D ldaa #'t' ; Load 't' into A staa waveType ; Update wave type to decreasing triangle + subd #1 ; Subtract 1 from D bra DonePrint ; Branch to DonePrint TriangleDec clra ; Clear A ldab outputVal ; Load the output value into B + ldy #buffer ; Load the address of buffer into Y jsr PrintDecimalWord; Print the lower byte of the output value; - cpd #0 ; Compare D to 0 - bne DonePrint ; If D != 0, done + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack + subd #1 ; Subtract 1 from D + cpd #$FFFF ; Compare D to $FFFF + bne DonePrint ; If D != $FFFF, done ldaa #'T' ; Load 'T' into A staa waveType ; Update wave type to increasing triangle - bra DonePrint ; Branch to DonePrint -TringleGood subd #1 ; Subtract 1 from D + clrb ; Clear B DonePrint stab outputVal ; Store updated output value + puly ; Restore Y from the stack puld ; Restore D from the stack rts ; Return from Caller +StartTimer5oc + PSHD + LDAA #%00100000 + STAA TIOS ; set CH5 Output Compare + STAA TIE ; set CH5 interrupt Enable + LDAA #%10000000 ; enable timer, Fast Flag Clear not set + STAA TSCR1 + LDAA #%00000000 ; TOI Off, TCRE Off, TCLK = BCLK/1 + STAA TSCR2 ; not needed if started from reset + + LDD #3000 ; 125usec with (24MHz/1 clock) + ADDD TCNTH ; for first interrupt + STD TC5H ; + + BSET TFLG1,%00100000 ; initial Timer CH5 interrupt flag Clear, not needed if fast clear set + LDAA #%00100000 + STAA TIE ; set CH5 interrupt Enable + PULD + RTS + +StopTimerCH5 + psha ; Save A to the stack + clra ; Clear A + staa TIE ; Stop Timers + pula ; Restore A from the stack + rts ; Return + + ;************************************************************************* ; PrintTime subroutine ; diff --git a/cmpen472hw10_McDonnell/bin/Project.abs b/cmpen472hw10_McDonnell/bin/Project.abs index 30d3567..6b1437f 100644 Binary files a/cmpen472hw10_McDonnell/bin/Project.abs and b/cmpen472hw10_McDonnell/bin/Project.abs differ diff --git a/cmpen472hw10_McDonnell/bin/Project.abs.phy b/cmpen472hw10_McDonnell/bin/Project.abs.phy index c70cbf6..e44254d 100644 --- a/cmpen472hw10_McDonnell/bin/Project.abs.phy +++ b/cmpen472hw10_McDonnell/bin/Project.abs.phy @@ -1,3 +1,4 @@ -S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877395F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627347 -S2060FFFF031804A +S0590000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E343732687731305F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E6162731E +S2060FFFE431BC1A +S2060FFFF0316B5F S9030000FC diff --git a/cmpen472hw10_McDonnell/bin/Project.abs.s19 b/cmpen472hw10_McDonnell/bin/Project.abs.s19 index 9d3012b..b79eb51 100644 --- a/cmpen472hw10_McDonnell/bin/Project.abs.s19 +++ b/cmpen472hw10_McDonnell/bin/Project.abs.s19 @@ -1,55 +1,61 @@ -S0580000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877395F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E61627347 +S0590000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E343732687731305F4D63446F6E6E656C6C5C62696E5C50726F6A6563742E6162731E S123300000000000000000000000000000000000000010000000000000000000000000009C S123302000000000001000000000000000000000000000000000000000000000000000007C -S106304000106811 -S1233100CF310086F15A03860C5ACBCC00015CC8CE36171635514C3B194C38804C3780864B -S1233120FF5A03CE3030FD304016354210EF1631D8CE3600163551163253CE3030FD304013 -S123314016355DCE303016327ACE3030A60027EAFD304016354214101631D8CE3600163562 -S12331605116325310EF20D214104D3880CE35BA16355116357E9727FA5A0116357720F33B -S12331804C3780FE302C087E302C8E00C82648CE00007E302CFE302A087E302A8E003C2658 -S12331A02ACE00007E302AFE3028087E30288E003C2618CE00007E3028FE3026087E30262B -S12331C08E00182606CE00007E30261631D8CE36001635511632530B3B3534860D16357719 -S12331E0860A163577CE3587163551FC30268C000A240736863016357732CD30001634D346 -S1233200863A163577FC30288C000A240736863016357732CD30001634D3863A163577FC9B -S1233220302A8C000A240736863016357732CD30001634D3B6304281682605FC3026200CBB -S1233240816D2605FC30282003FC302A16326230313A3D34CE358F163551CE3030163551D6 -S1233260303D3B34CE000A181037B7D4CE000A58585858EAB05B01303A3D3B35A630182752 -S123328000E08174266DA620812027FA1410FC30263B163480B7E48C0018182400A28C0016 -S12332A000182D009B7C3026A61F813A18260090FC30283B163480B7E48C003C247E8C0020 -S12332C0002D797C3028A61F813A2670FC302A3B163480B7E48C003C245E8C00002D597C8C -S12332E0302AA61F81002650877A302C10EF3A3A3A206F8168260BE630C10026497A3042CF -S12333002060816D260BE630C100263A7A304220518173260BE630C100262B7A30422042DB -S123332081712609E630C100261C063168091634172713163365202A3A7C302A3A7C3028F6 -S12333403A7C302610EF348620163577163577163577163577CE3595163551CE359D16355D -S12333605130313A3D353B3416348035A61F163480812B2713812D271A812A2721B7E53159 -S1233380B7E41810B7D4201F7D302E31B7E4F3302E20147D302E31B7E4B3302E2009B7E4F4 -S12333A031138D0000264D8C270F2E488CD8F12D4314101631D8368620163577163577160F -S12333C0357716357732303416355130FD304016354236863D16357732CD30001634D38791 -S12333E07A302F1631D8CE360016355116325310EF3A313D862016357716357716357716ED -S12334003577CE35951635518620163577CE35AB163551303A313D353B34C77B302FCD002C -S123342000A6308139222081302D08028D0004221620EE812B271B812D2717812A271381B7 -S12334402F270F81002723876A008604B702303A313D7A302FA61E81302DEC813922E8CB36 -S123346001C10122E2CD000020B7A61E81302DD7813922D3B6302F27CE87B702303A313D93 -S12334803BCD0000E630272EC12B272AC12D2726C12A2722C12F271EC13A271AC12027167A -S12334A0C1302D17C1392213C03037CC000A13B7C63319ED20CE87B7023A3D8604B7023ABC -S12334C03D343536A67F27056A3020F8876A303231303D34353B8C0000274C2D5336353456 -S12334E08630CE3013CD000516354B3031876A4032CE000A18108E00002708CB306B60B79B -S1233500D420EE8C000026F3B6302F812D26026A60CE30131634C1163551FD3024CE301351 -S12335201635423A31303D86301635773A31303D36862D7A302F3240800150C001C3000148 -S1233540209B36876A300436FB323D6A300436FB3D36A630270516357720F7323D36353486 -S123356016357E27FB810D270A6A3016357703270220ED3031323D4FCC80FC5ACF3D4FCC20 -S1233580200396CF3D873D5463616C633E2000434D443E20004572726F723E2000496E7692 -S12335A0616C696420496E707574004F766572666C6F77204572726F72000D0A436C6F6327 -S12335C06B2073746F7070656420616E64205479706577726974652070726F6772616D20E5 -S12335E0737461727465642E0D0A596F75206D617920747970652062656C6F772E0D0A0087 -S12336002020202020202020202020202020202020202020202000436F6D6D616E64733A7A -S12336200D0A743A20536574207468652074696D6520696E20666F726D61742048483A4D6E -S12336404D3A53530D0A683A20446973706C61792074686520686F757273206F6E207468DF -S1233660652037207365676D656E7420646973706C6179730D0A6D3A20446973706C61793A -S123368020746865206D696E75746573206F6E207468652037207365676D656E74206469EB -S12336A073706C6179730D0A733A20446973706C617920746865207365636F6E6473206FB1 -S12336C06E207468652037207365676D656E7420646973706C6179730D0A713A2053746F0C -S12336E0702074686520636C6F636B20616E6420656E7465722074797065777269746572B9 -S10637000D0A00AB -S105FFF031805A +S1103040000010730000000BB808000071C0 +S1233100CF310086F15A03860C5ACBCC00015CC8CE36CB1636054C3B194C38804C378086E2 +S1233120FF5A0310EFCE3030FD3041163611CC00007C30457A30441632C4B6304B27FB87A6 +S12331407A304B1631DDFC3045BC304925EC1632E320D214104D3880CE366E163605163646 +S1233160329727FA5A0116362B20F34C378010EFFE302C087E302C8E00C8263FCE00007E37 +S1233180302CFE302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C26189B +S12331A0CE00007E3028FE3026087E30268E00182606CE00007E30261632E90BFC3047D341 +S12331C05A5C5A4C4E2086017A304BFC3045C300017C3045BC304925031632E30B3B35B6C6 +S12331E0304C81541827008A8174182700AC81511827002B81711827005087F63044CD3026 +S12332000016358736860D16362B860A16362B32C300018C0100182600A4C71820009F8707 +S1233220C6FFCD300016358736860D16362B860A16362B3287F63044C300018C01001826FD +S1233240007CC786717A304C207487C7CD300016358736860D16362B860A16362B3287F693 +S12332603044C300018C01002654C786517A304C204C87F63044CD300016358736860D166C +S1233280362B860A16362B32C300018C0100262E86747A304C830001202487F63044CD3045 +S12332A00016358736860D16362B860A16362B328300018CFFFF260686547A304CC77B3043 +S12332C044313A3D3B86205A405A4C86805A4686005A4DCC0BB8D3445C5A4C4E2086205AF4 +S12332E04C3A3D36875A4C323D3BB6304381682605FC3026200C816D2605FC30282003FCB3 +S1233300302A1633163A3D34CE3643163605CE3030163605303D3B34CE000A181037B7D490 +S1233320CE000A58585858EAB05B01303A3D3B35A630182700E08174266DA620812027FA3F +S12333401410FC30263B163534B7E48C0018182400A28C0000182D009B7C3026A61F813A5E +S123336018260090FC30283B163534B7E48C003C247E8C00002D797C3028A61F813A26704C +S1233380FC302A3B163534B7E48C003C245E8C00002D597C302AA61F81002650877A302C33 +S12333A010EF3A3A3A206F8168260BE630C10026497A30432060816D260BE630C100263AAA +S12333C07A304320518173260BE630C100262B7A3043204281712609E630C100261C06317E +S12333E053091634CB2713163419202A3A7C302A3A7C30283A7C302610EF34862016362BF7 +S123340016362B16362B16362BCE3649163605CE365116360530313A3D353B3416353435CF +S1233420A61F163534812B2713812D271A812A2721B7E531B7E41810B7D4201F7D302E3116 +S1233440B7E4F3302E20147D302E31B7E4B3302E2009B7E431138D0000264D8C270F2E4850 +S12334608CD8F12D4314101632E936862016362B16362B16362B16362B323034163605305F +S1233480FD30411635F636863D16362B32CD3000163587877A302F1632E9CE36B41636056E +S12334A016330710EF3A313D862016362B16362B16362B16362BCE364916360586201636FF +S12334C02BCE365F163605303A313D353B34C77B302FCD0000A6308139222081302D080265 +S12334E08D0004221620EE812B271B812D2717812A2713812F270F81002723876A00860406 +S1233500B702303A313D7A302FA61E81302DEC813922E8CB01C10122E2CD000020B7A61EF1 +S123352081302DD7813922D3B6302F27CE87B702303A313D3BCD0000E630272EC12B272A51 +S1233540C12D2726C12A2722C12F271EC13A271AC1202716C1302D17C1392213C03037CC12 +S1233560000A13B7C63319ED20CE87B7023A3D8604B7023A3D343536A67F27056A3020F873 +S1233580876A303231303D34353B8C0000274C2D533635348630CE3013CD00051635FF3061 +S12335A031876A4032CE000A18108E00002708CB306B60B7D420EE8C000026F3B6302F811C +S12335C02D26026A60CE3013163575163605FD3024CE30131635F63A31303D863016362BFE +S12335E03A31303D36862D7A302F3240800150C001C30001209B36876A300436FB323D6A45 +S1233600300436FB3D36A630270516362B20F7323D36353416363227FB810D270A6A301621 +S1233620362B03270220ED3031323D4FCC80FC5ACF3D4FCC200396CF3D873D5463616C6394 +S12336403E2000434D443E20004572726F723E2000496E76616C696420496E707574004F28 +S1233660766572666C6F77204572726F72000D0A436C6F636B2073746F7070656420616E06 +S123368064205479706577726974652070726F6772616D20737461727465642E0D0A596F99 +S12336A075206D617920747970652062656C6F772E0D0A002020202020202020202020204A +S12336C02020202020202020202000436F6D6D616E64733A0D0A743A2053657420746865C8 +S12336E02074696D6520696E20666F726D61742048483A4D4D3A53530D0A683A20446973FA +S1233700706C61792074686520686F757273206F6E207468652037207365676D656E742055 +S1233720646973706C6179730D0A6D3A20446973706C617920746865206D696E75746573E2 +S1233740206F6E207468652037207365676D656E7420646973706C6179730D0A733A2044EC +S12337606973706C617920746865207365636F6E6473206F6E207468652037207365676DC2 +S1233780656E7420646973706C6179730D0A713A2053746F702074686520636C6F636B2020 +S11A37A0616E6420656E74657220747970657772697465720D0A0007 +S105FFE431BC2A +S105FFF0316B6F S9030000FC diff --git a/cmpen472hw10_McDonnell/bin/main.dbg b/cmpen472hw10_McDonnell/bin/main.dbg index 69646bb..58564c7 100644 --- a/cmpen472hw10_McDonnell/bin/main.dbg +++ b/cmpen472hw10_McDonnell/bin/main.dbg @@ -59,6 +59,14 @@ CRGFLG EQU $0037 ; Clock and Reset Generator Flags CRGINT EQU $0038 ; Clock and Reset Generator Interrupts RTICTL EQU $003B ; Real Time Interrupt Control +TIOS EQU $0040 ; Timer Input Capture (IC) or Output Compare (OC) select +TIE EQU $004C ; Timer interrupt enable register +TCNTH EQU $0044 ; Timer free runing main counter +TSCR1 EQU $0046 ; Timer system control 1 +TSCR2 EQU $004D ; Timer system control 2 +TFLG1 EQU $004E ; Timer interrupt flag 1 +TC5H EQU $005A ; Timer channel 5 register + CR equ $0d ; carriage return, ASCII 'Return' key LF equ $0a ; line feed, ASCII 'next line' character NULL equ $00 ; NULL Terminator character @@ -89,10 +97,27 @@ numBuf dc.b $0000 ; Used by ReadDecimal for reading number operator dc.b $0000 ; Used by ReadDecimal for reading numbers inputBuffer ds.b $0010 ; Input Buffer Length + dc.b NULL lenInput dc.w $0010 ; Length of the Input Buffer -outputBuf dc.b 'h' ; Used to control what to output on 7 segment display +outputBuf dc.b 's' ; Used to control what to output on 7 segment display + +outputVal dc.b $00 ; Used to track the output value of the wave + +outputCnt dc.w $0000 ; Used to track how many values have been outputted + +interval dc.w 3000 ; Used to set the timer module based on clock cycles + +numPoints dc.w 2048 ; Max Number of points for waves + +timeTrigger dc.b $00 ; Tracks when timer is triggered + +waveType dc.b 'q' ; Used to track wave type 'T' for increasing triangle, + ; 't' for decreasing triangle, + ; 'Q' for square high + ; 'q' for square low + ; 'S' for sawtooth * * There is a section Data Section at the end of the file @@ -103,6 +128,12 @@ outputBuf dc.b 'h' ; Used to control what to output on 7 se dc.w rtiisr ; Real Time Interrupt vector * ************************************************************************** +* Timer Interrupt Vector Section: address used [ $FFE4 to $FFE5 ] RAM Memory +* + org $FFE4 ; Timer channel 5 interrupt vector setup, on simulator + dc.w oc5isr +* +************************************************************************** * Program Section: address used [ $3100 to $3FFF ] RAM Memory * org $3100 ; Program start address, in RAM @@ -128,34 +159,28 @@ pgstart lds #$3100 ; initialize the stack pointer ldaa #$FF ; Two 7 segment displays on PORTB staa DDRB ; Set all of PORTB as output - ldx #inputBuffer ; Load the address of inputBuffer into X - ldy lenInput ; Load the length of inputBuffer into Y - jsr Zeros ; Zero out inputBuffer cli ; Enable interrupts - jsr PrintTime ; Jump to PrintTime to write to serial console - ldx #spacer ; Load the address of spacer into X - jsr WriteString ; Write the spacer string to the output - jsr PrintPrompt ; Jump to PrintPrompt to write to serial console mainLoop ldx #inputBuffer ; Load the address of inputBuffer into X ldy lenInput ; Load the length of inputBuffer into Y jsr ReadString ; Jump to ReadString to read input - ldx #inputBuffer ; Load the address of inputBuffer into X - jsr ExecuteCommand ; Jump to ExecuteCommand + ldd #0 ; Clear D + std outputCnt ; Clear outputCnt + staa outputVal ; Clear outputVal - ldx #inputBuffer ; Load the address of inputBuffer into X - ldaa 0,x ; Load first character from inputBuffer into A - beq mainLoop ; If A == 0, branch to mainLoop, only zero if Solve was called - ldy lenInput ; Load the length of inputBuffer into Y - jsr Zeros ; Zero out inputBuffer + jsr StartTimer5oc ; Start Timer on CH5 - sei ; Disable interrupts - jsr PrintTime ; Jump to PrintTime to print new time - ldx #spacer ; Load the address of spacer into X - jsr WriteString ; Write the spacer string to the output - jsr PrintPrompt ; Jump to PrintPrompt to write to serial console - cli ; Enable interrupts +looooop ldaa timeTrigger + beq looooop + clra + staa timeTrigger + jsr PrintWave ; Jump to PrintWave + ldd outputCnt + cpd numPoints + blo looooop + + jsr StopTimerCH5 bra mainLoop ; Loop back to mainLoop always @@ -194,6 +219,7 @@ twLoop jsr getchar ; Read a character from the serial conso ; rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag + cli ; Enable interrupts ldx counter ; Load counter into X inx ; Increment counter by 1 stx counter ; Save X to counter @@ -223,11 +249,153 @@ rtiisr bset CRGFLG,%10000000; Clear RTI Interrupt Flag ldx #0 ; Reset the hours stx hours ; Save the updated hours rtidone jsr PrintTime ; Jump to PrintTime - ldx #spacer ; Load the address of spacer into X - jsr WriteString ; Write the spacer string to the output - jsr PrintPrompt ; Jump to PrintPrompt rtiSkip RTI ; Return from RTI ISR +oc5isr ldd interval ; Load the interval for the next clock cycle + addd TC5H ; for next interrupt + std TC5H ; + bset TFLG1,%00100000 ; Clear CH5 interrupt flag + ldaa #1 ; Load 1 into A + staa timeTrigger ; Signal that timer went off + ldd outputCnt ; Load the count of values outputed into D + addd #1 ; Increase output count by 1 + std outputCnt ; Update the count of outputted values + cpd numPoints ; Compare D to numPoints + blo oc5Done ; If D < numPoints, Done + jsr StopTimerCH5 ; Stop Channel 5 Timer +oc5Done RTI ; Return from interrupt + +PrintWave + pshd ; Save D to the stack + pshy ; Save Y to the stack + ldaa waveType ; Load the waveType into A + cmpa #'T' ; Compare to 'T' + lbeq TriangleInc ; If A == 'T', triangle wave increasing + cmpa #'t' ; Compare A to 't' + lbeq TriangleDec ; If A == 't', triangle wave decreasing + cmpa #'Q' ; Compare A to 'Q' + lbeq SquareWaveH ; If A == 'Q', square wave high + cmpa #'q' ; Compare A to 'q' + lbeq SquareWaveL ; If A == 'q', square wave low +SawToothWav clra ; Clear A + ldab outputVal ; Load the output value into B + ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack + addd #1 ; Increment output value by 1 + cpd #256 ; Compare D to 256 + lbne DonePrint ; If D != 256, Done + clrb ; Reset to Zero + lbra DonePrint ; Branch to DonePrint +SquareWaveH clra ; Clear A + ldab #255 ; Load 255 into B + ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack + clra ; Clear A + ldab outputVal ; Load the output value into B + addd #1 ; Add 1 to D + cpd #256 ; Compare D to 256 + lbne DonePrint ; If D != 256, done + clrb ; Reset B to zero + ldaa #'q' ; Load 'q' into A + staa waveType ; Update wave type to square wave low + bra DonePrint ; Branch to DonePrint +SquareWaveL clra ; Clear A + clrb ; Reset B to zero + ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack + clra ; Clear A + ldab outputVal ; Load the output value into B + addd #1 ; Add 1 to D + cpd #256 ; Compare D to 256 + bne DonePrint ; If D != 256, done + clrb ; Reset B to zero + ldaa #'Q' ; Load 'Q' into A + staa waveType ; Update wave type to square wave low + bra DonePrint ; Branch to DonePrint +TriangleInc clra ; Clear A + ldab outputVal ; Load the output value into B + ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack + addd #1 ; Add 1 to D + cpd #256 ; Compare D to 256 + bne DonePrint ; If D != 256, done + ldaa #'t' ; Load 't' into A + staa waveType ; Update wave type to decreasing triangle + subd #1 ; Subtract 1 from D + bra DonePrint ; Branch to DonePrint +TriangleDec clra ; Clear A + ldab outputVal ; Load the output value into B + ldy #buffer ; Load the address of buffer into Y + jsr PrintDecimalWord; Print the lower byte of the output value; + psha ; Save A to the stack + ldaa #CR ; Load CR into A + jsr putchar ; Write CR to serial console + ldaa #LF ; Load LF into A + jsr putchar ; Write LF to serial console + pula ; Restore A from the stack + subd #1 ; Subtract 1 from D + cpd #$FFFF ; Compare D to $FFFF + bne DonePrint ; If D != $FFFF, done + ldaa #'T' ; Load 'T' into A + staa waveType ; Update wave type to increasing triangle + clrb ; Clear B +DonePrint stab outputVal ; Store updated output value + puly ; Restore Y from the stack + puld ; Restore D from the stack + rts ; Return from Caller + +StartTimer5oc + PSHD + LDAA #%00100000 + STAA TIOS ; set CH5 Output Compare + STAA TIE ; set CH5 interrupt Enable + LDAA #%10000000 ; enable timer, Fast Flag Clear not set + STAA TSCR1 + LDAA #%00000000 ; TOI Off, TCRE Off, TCLK = BCLK/1 + STAA TSCR2 ; not needed if started from reset + + LDD #3000 ; 125usec with (24MHz/1 clock) + ADDD TCNTH ; for first interrupt + STD TC5H ; + + BSET TFLG1,%00100000 ; initial Timer CH5 interrupt flag Clear, not needed if fast clear set + LDAA #%00100000 + STAA TIE ; set CH5 interrupt Enable + PULD + RTS + +StopTimerCH5 + psha ; Save A to the stack + clra ; Clear A + staa TIE ; Stop Timers + pula ; Restore A from the stack + rts ; Return + + ;************************************************************************* ; PrintTime subroutine ; @@ -248,45 +416,6 @@ rtiSkip RTI ; Return from RTI ISR PrintTime pshd ; Save D to the stack - pshy ; Save Y to the stack - pshx ; Save X to the stack - ldaa #CR ; Load the character CR into A - jsr putchar ; Write the character to the serial - ldaa #LF ; Load the character LF into A - jsr putchar ; Write the character to the serial - ldx #clock ; Load the address of the clock prompt into X - jsr WriteString ; Write the string to serial - ldd hours ; Load the hours into D - cpd #10 ; Compare D to 10 - bhs goodHours ; If D >= goodHours - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodHours ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #':' ; Load the character ':' into A - jsr putchar ; Write the character to the serial - ldd minutes ; Load the minutes into D - cpd #10 ; Compare D to 10 - bhs goodMins ; If D >= goodMins - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodMins ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial - ldaa #':' ; Load the character ':' into A - jsr putchar ; Write the character to the serial - ldd seconds ; Load the seconds into D - cpd #10 ; Compare D to 10 - bhs goodSecs ; If D >= goodSecs - psha ; Save A to the stack - ldaa #'0' ; Load '0' character into A - jsr putchar ; Print '0' to the serial - pula ; Restore A from the stack -goodSecs ldy #buffer ; Load the address of buffer into Y - jsr PrintDecimalWord; Print the number to the serial ldaa outputBuf ; Load outputBuf into A cmpa #'h' ; Compare A to 'h' bne pTimeIsM ; If A != 'h', branch to pTimeIsM @@ -298,8 +427,6 @@ pTimeIsM cmpa #'m' ; Compare A to 'm' bra skipRest ; Jump to skipRest pTimeIsS ldd seconds ; Load seconds into D skipRest jsr TimeOnPortB ; Call TimeOnPortB to output time - pulx ; Restore X from the stack - puly ; Restore Y from the stack puld ; Restore D from the stack rts ; Return to caller diff --git a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.o b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.o index 30d3567..6b1437f 100644 Binary files a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.o and b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.o differ diff --git a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx index 4207f45..3a1ae49 100644 --- a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx +++ b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/ObjectCode/main.asm.sx @@ -1,55 +1,61 @@ -S0840000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E3437326877395F4D63446F6E6E656C6C5C636D70656E3437326877395F4D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726DC7 +S0860000433A5C55736572735C4A61636F62204D63446F6E6E656C6C5C446F63756D656E74735C434D50454E2D3437322D48575C636D70656E343732687731305F4D63446F6E6E656C6C5C636D70656E343732687731305F4D63446F6E6E656C6C5F446174615C5374616E646172645C4F626A656374436F64655C6D61696E2E61736D2E70726D75 S123300000000000000000000000000000000000000010000000000000000000000000009C S123302000000000001000000000000000000000000000000000000000000000000000007C -S106304000106811 -S105FFF031805A -S1233100CF310086F15A03860C5ACBCC00015CC8CE36171635514C3B194C38804C3780864B -S1233120FF5A03CE3030FD304016354210EF1631D8CE3600163551163253CE3030FD304013 -S123314016355DCE303016327ACE3030A60027EAFD304016354214101631D8CE3600163562 -S12331605116325310EF20D214104D3880CE35BA16355116357E9727FA5A0116357720F33B -S12331804C3780FE302C087E302C8E00C82648CE00007E302CFE302A087E302A8E003C2658 -S12331A02ACE00007E302AFE3028087E30288E003C2618CE00007E3028FE3026087E30262B -S12331C08E00182606CE00007E30261631D8CE36001635511632530B3B3534860D16357719 -S12331E0860A163577CE3587163551FC30268C000A240736863016357732CD30001634D346 -S1233200863A163577FC30288C000A240736863016357732CD30001634D3863A163577FC9B -S1233220302A8C000A240736863016357732CD30001634D3B6304281682605FC3026200CBB -S1233240816D2605FC30282003FC302A16326230313A3D34CE358F163551CE3030163551D6 -S1233260303D3B34CE000A181037B7D4CE000A58585858EAB05B01303A3D3B35A630182752 -S123328000E08174266DA620812027FA1410FC30263B163480B7E48C0018182400A28C0016 -S12332A000182D009B7C3026A61F813A18260090FC30283B163480B7E48C003C247E8C0020 -S12332C0002D797C3028A61F813A2670FC302A3B163480B7E48C003C245E8C00002D597C8C -S12332E0302AA61F81002650877A302C10EF3A3A3A206F8168260BE630C10026497A3042CF -S12333002060816D260BE630C100263A7A304220518173260BE630C100262B7A30422042DB -S123332081712609E630C100261C063168091634172713163365202A3A7C302A3A7C3028F6 -S12333403A7C302610EF348620163577163577163577163577CE3595163551CE359D16355D -S12333605130313A3D353B3416348035A61F163480812B2713812D271A812A2721B7E53159 -S1233380B7E41810B7D4201F7D302E31B7E4F3302E20147D302E31B7E4B3302E2009B7E4F4 -S12333A031138D0000264D8C270F2E488CD8F12D4314101631D8368620163577163577160F -S12333C0357716357732303416355130FD304016354236863D16357732CD30001634D38791 -S12333E07A302F1631D8CE360016355116325310EF3A313D862016357716357716357716ED -S12334003577CE35951635518620163577CE35AB163551303A313D353B34C77B302FCD002C -S123342000A6308139222081302D08028D0004221620EE812B271B812D2717812A271381B7 -S12334402F270F81002723876A008604B702303A313D7A302FA61E81302DEC813922E8CB36 -S123346001C10122E2CD000020B7A61E81302DD7813922D3B6302F27CE87B702303A313D93 -S12334803BCD0000E630272EC12B272AC12D2726C12A2722C12F271EC13A271AC12027167A -S12334A0C1302D17C1392213C03037CC000A13B7C63319ED20CE87B7023A3D8604B7023ABC -S12334C03D343536A67F27056A3020F8876A303231303D34353B8C0000274C2D5336353456 -S12334E08630CE3013CD000516354B3031876A4032CE000A18108E00002708CB306B60B79B -S1233500D420EE8C000026F3B6302F812D26026A60CE30131634C1163551FD3024CE301351 -S12335201635423A31303D86301635773A31303D36862D7A302F3240800150C001C3000148 -S1233540209B36876A300436FB323D6A300436FB3D36A630270516357720F7323D36353486 -S123356016357E27FB810D270A6A3016357703270220ED3031323D4FCC80FC5ACF3D4FCC20 -S1233580200396CF3D873D5463616C633E2000434D443E20004572726F723E2000496E7692 -S12335A0616C696420496E707574004F766572666C6F77204572726F72000D0A436C6F6327 -S12335C06B2073746F7070656420616E64205479706577726974652070726F6772616D20E5 -S12335E0737461727465642E0D0A596F75206D617920747970652062656C6F772E0D0A0087 -S12336002020202020202020202020202020202020202020202000436F6D6D616E64733A7A -S12336200D0A743A20536574207468652074696D6520696E20666F726D61742048483A4D6E -S12336404D3A53530D0A683A20446973706C61792074686520686F757273206F6E207468DF -S1233660652037207365676D656E7420646973706C6179730D0A6D3A20446973706C61793A -S123368020746865206D696E75746573206F6E207468652037207365676D656E74206469EB -S12336A073706C6179730D0A733A20446973706C617920746865207365636F6E6473206FB1 -S12336C06E207468652037207365676D656E7420646973706C6179730D0A713A2053746F0C -S12336E0702074686520636C6F636B20616E6420656E7465722074797065777269746572B9 -S10637000D0A00AB +S1103040000010730000000BB808000071C0 +S105FFF0316B6F +S105FFE431BC2A +S1233100CF310086F15A03860C5ACBCC00015CC8CE36CB1636054C3B194C38804C378086E2 +S1233120FF5A0310EFCE3030FD3041163611CC00007C30457A30441632C4B6304B27FB87A6 +S12331407A304B1631DDFC3045BC304925EC1632E320D214104D3880CE366E163605163646 +S1233160329727FA5A0116362B20F34C378010EFFE302C087E302C8E00C8263FCE00007E37 +S1233180302CFE302A087E302A8E003C262ACE00007E302AFE3028087E30288E003C26189B +S12331A0CE00007E3028FE3026087E30268E00182606CE00007E30261632E90BFC3047D341 +S12331C05A5C5A4C4E2086017A304BFC3045C300017C3045BC304925031632E30B3B35B6C6 +S12331E0304C81541827008A8174182700AC81511827002B81711827005087F63044CD3026 +S12332000016358736860D16362B860A16362B32C300018C0100182600A4C71820009F8707 +S1233220C6FFCD300016358736860D16362B860A16362B3287F63044C300018C01001826FD +S1233240007CC786717A304C207487C7CD300016358736860D16362B860A16362B3287F693 +S12332603044C300018C01002654C786517A304C204C87F63044CD300016358736860D166C +S1233280362B860A16362B32C300018C0100262E86747A304C830001202487F63044CD3045 +S12332A00016358736860D16362B860A16362B328300018CFFFF260686547A304CC77B3043 +S12332C044313A3D3B86205A405A4C86805A4686005A4DCC0BB8D3445C5A4C4E2086205AF4 +S12332E04C3A3D36875A4C323D3BB6304381682605FC3026200C816D2605FC30282003FCB3 +S1233300302A1633163A3D34CE3643163605CE3030163605303D3B34CE000A181037B7D490 +S1233320CE000A58585858EAB05B01303A3D3B35A630182700E08174266DA620812027FA3F +S12333401410FC30263B163534B7E48C0018182400A28C0000182D009B7C3026A61F813A5E +S123336018260090FC30283B163534B7E48C003C247E8C00002D797C3028A61F813A26704C +S1233380FC302A3B163534B7E48C003C245E8C00002D597C302AA61F81002650877A302C33 +S12333A010EF3A3A3A206F8168260BE630C10026497A30432060816D260BE630C100263AAA +S12333C07A304320518173260BE630C100262B7A3043204281712609E630C100261C06317E +S12333E053091634CB2713163419202A3A7C302A3A7C30283A7C302610EF34862016362BF7 +S123340016362B16362B16362BCE3649163605CE365116360530313A3D353B3416353435CF +S1233420A61F163534812B2713812D271A812A2721B7E531B7E41810B7D4201F7D302E3116 +S1233440B7E4F3302E20147D302E31B7E4B3302E2009B7E431138D0000264D8C270F2E4850 +S12334608CD8F12D4314101632E936862016362B16362B16362B16362B323034163605305F +S1233480FD30411635F636863D16362B32CD3000163587877A302F1632E9CE36B41636056E +S12334A016330710EF3A313D862016362B16362B16362B16362BCE364916360586201636FF +S12334C02BCE365F163605303A313D353B34C77B302FCD0000A6308139222081302D080265 +S12334E08D0004221620EE812B271B812D2717812A2713812F270F81002723876A00860406 +S1233500B702303A313D7A302FA61E81302DEC813922E8CB01C10122E2CD000020B7A61EF1 +S123352081302DD7813922D3B6302F27CE87B702303A313D3BCD0000E630272EC12B272A51 +S1233540C12D2726C12A2722C12F271EC13A271AC1202716C1302D17C1392213C03037CC12 +S1233560000A13B7C63319ED20CE87B7023A3D8604B7023A3D343536A67F27056A3020F873 +S1233580876A303231303D34353B8C0000274C2D533635348630CE3013CD00051635FF3061 +S12335A031876A4032CE000A18108E00002708CB306B60B7D420EE8C000026F3B6302F811C +S12335C02D26026A60CE3013163575163605FD3024CE30131635F63A31303D863016362BFE +S12335E03A31303D36862D7A302F3240800150C001C30001209B36876A300436FB323D6A45 +S1233600300436FB3D36A630270516362B20F7323D36353416363227FB810D270A6A301621 +S1233620362B03270220ED3031323D4FCC80FC5ACF3D4FCC200396CF3D873D5463616C6394 +S12336403E2000434D443E20004572726F723E2000496E76616C696420496E707574004F28 +S1233660766572666C6F77204572726F72000D0A436C6F636B2073746F7070656420616E06 +S123368064205479706577726974652070726F6772616D20737461727465642E0D0A596F99 +S12336A075206D617920747970652062656C6F772E0D0A002020202020202020202020204A +S12336C02020202020202020202000436F6D6D616E64733A0D0A743A2053657420746865C8 +S12336E02074696D6520696E20666F726D61742048483A4D4D3A53530D0A683A20446973FA +S1233700706C61792074686520686F757273206F6E207468652037207365676D656E742055 +S1233720646973706C6179730D0A6D3A20446973706C617920746865206D696E75746573E2 +S1233740206F6E207468652037207365676D656E7420646973706C6179730D0A733A2044EC +S12337606973706C617920746865207365636F6E6473206F6E207468652037207365676DC2 +S1233780656E7420646973706C6179730D0A713A2053746F702074686520636C6F636B2020 +S11A37A0616E6420656E74657220747970657772697465720D0A0007 S9033100CB diff --git a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdt b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdt index 2273a25..d623bdd 100644 Binary files a/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdt and b/cmpen472hw10_McDonnell/cmpen472hw10_McDonnell_Data/Standard/TargetDataWindows.tdt differ diff --git a/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/CWSettingsWindows.stg b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/CWSettingsWindows.stg index 1f2028b..f97000f 100644 Binary files a/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/CWSettingsWindows.stg and b/cmpen472hw9_McDonnell/cmpen472hw9_McDonnell_Data/CWSettingsWindows.stg differ diff --git a/exam2prep/Full_Chip_Simulation.ini b/exam2prep/Full_Chip_Simulation.ini index 7eb98ae..76b7b44 100644 --- a/exam2prep/Full_Chip_Simulation.ini +++ b/exam2prep/Full_Chip_Simulation.ini @@ -10,7 +10,7 @@ Target=sim Layout=ASM_layout.hwl LoadDialogOptions=AUTOERASEANDFLASH NORUNAFTERLOAD CPU=HC12 -MainFrame=0,1,-1,-1,-1,-1,625,183,1726,1199 +MainFrame=0,1,-1,-1,-1,-1,417,44,1518,1060 Configuration=Full_Chip_Simulation.hwc Statusbar=1 ShowToolbar=1 diff --git a/exam2prep/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt b/exam2prep/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt index 4201423..f4bcacb 100644 Binary files a/exam2prep/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt and b/exam2prep/cmpen472_hw8McDonnell_Data/Standard/TargetDataWindows.tdt differ -- cgit v1.2.3