;Toggling PORTT0 to sound the buzzer for Freescale Student Project Board Using HCS12 MCU Module ;On Student Project Board, PT0 of PORTT is connected to buzzer/speaker permanently. It is accessed by BZ jumper. ;MAKE SURE jumper for BZ (buzzer) is set. BZ JUMPER is part of group of jumpers called UFEA right next to the Buzzer itself ;This program toggles PT0 to sound the buzzer. Change the delay size to get a different sound ;See Chapter 4 of Mazidi & Causey HCS12 book ;In Codewarrior, Make sure you are in TBDML Mode before downloading ;Press F7 (to Make), then F5(Debug) to downLOAD,and F5 once more to start the program execution ABSENTRY Entry ; for absolute assembly: mark this as application entry point ; Include derivative-specific definitions INCLUDE 'mc9s12dp256.inc' ;CPU used by CPU Module (Change it for your CPU module, C128 or DT512 ;----------------------USE $1000-$2FFF for Scratch Pad R1 EQU $1001 R2 EQU $1002 R3 EQU $1003 ;code section ORG $4000 ;Flash ROM address for Entry: LDS #$4000 ;Stack BSET DDRT,%00000001 ;PTT0 as Output pin for buzzer ;-------Sound the Buzzer at PTT0 BACK BSET PTT,$01 ;PTT0=1 JSR DELAY BCLR PTT,$01 ;PTT0=0 JSR DELAY BRA BACK ;Keep toggling buzzer ;----------DELAY DELAY PSHA ;Save Reg A on Stack LDAA #10 ;Change this value to see STAA R3 ;how fast LEDs Toggle ;--10 msec delay. The HCS12 MCU Module has XTAL=4MHz ;Freq. for Instruction Clock Cycle is 2MHz (1/2 of 4MHz). ;(1/2MHz) x 10 Clk x 10 x 200=10 msec. Overheads are excluded in this calculation. L3 LDAA #10 STAA R2 L2 LDAA #200 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 ;************************************************************** ;* Interrupt Vectors * ;************************************************************** ORG $FFFE DC.W Entry ;Reset Vector. CPU wakes here and it is sent to start of the code at $4000