;Toggling PT5 to sound the buzzer for Dragon12 Plus Trainer Board ;with D-Bug12 Program installed. This code is for AsmIde or MiniIde Assemblers ;PT5 of PORTT is connected to buzzer/speaker on Dragon12+ board ;This program toggles PT5 to sound the buzzer. Change the delay size to get a different sound ;See Chapter 4 of Mazidi&Causey HCS12 book ;In Dragon12+ RAM address is from $1000-3FFF ;Use $2000-3BFF for code since $3C00-3FFF are used by the D-Bug12 for Interrupts ;We use RAM addresses starting at $1000 for scratch pad (variables) and $1FFF for Stack ;Make sure SW7=LOAD (SW7 is 2-bit red DIP Switch on bottom right side of the board and must be 00, or LOAD) #include "C:\Reg9s12.H" ;----------------------USE $1000-$2FFF for Scratch Pad and stack R1 EQU $1001 R2 EQU $1002 R3 EQU $1003 ;code section ORG $2000 ;RAM address for Code LDS #$2000 ;Stack BSET DDRT,%00100000 ;PTT5 as Output pin for buzzer ;-------Sound the Buzzer at PTT5 BACK BSET PTT,%00100000 ;PTT5=1 JSR DELAY BCLR PTT,%00100000 ;PTT5=0 JSR DELAY BRA BACK ;Keep toggling buzzer ;-------- DELAY DELAY PSHA ;Save Reg A on Stack LDAA #10 ;Chnage this value to hear differnt sound STAA R3 ;--10 msec delay. The D-Bug12 works at speed of 48MHz with XTAL=8MHz on Dragon12+ board ;Freq. for Instruction Clock Cycle (and Bus Cycle) is 24MHz (1/2 of 48Mhz). ;(1/24MHz) x 10 Clk x240x10=1 msec. Overheads are excluded in this calculation. L3 LDAA #10 STAA R2 L2 LDAA #240 STAA R1 L1 NOP ;1 Intruction Clk Cycle NOP ;1 NOP ;1 DEC R1 ;4 BNE L1 ;3 DEC R2 ;Total Instr.Clk=10 BNE L2 DEC R3 BNE L3 ;-------------- PULA ;Restore Reg A RTS ;-------------------