;Testing HCS12 MCU Module (from Freescale or Axiom) by Toggling PORTB in Assembly Language ;The HCS12 MCU Modules can be used with Freescale Student Project Board and they are made by Axiom. ;They can also be used as stand-alone without the Project Board. This Assembly tests the MCU Module without the Project Board ;The HCs12 MCU Modules are either C128 (HCSxxx128), DT256 (HCSxxx256), or XDT512 (HCSxxx512). See the designation on your Module. ;These HCS12 MCU Module comes with BDM and ready to work with CodeWarrior(only). Connect the module to the x86 PC USB port via a USB cable. ;The MCU module has 4-bit green LEDs and are located between Brown POT and Blue DIP SW. ;The LEDs are connected to PORTB7-PORTB4 via row of jumpers right in front of LEDs. ;Make sure the Jumpers are set for LEDs. They are designateed as LED1-LED4 ;Make sure the VB jumper for PWRr_SEL (next to power jack) is ALSO set. VB is the middle Jumper and allows the power come from USB cable (500 mA Maximum) ;WHEN USB CABLE IS THE EXCLEUSIVE PROVIDER OF POWER TO CPU MODULE, NEVER USE IT TO DRIVE POWER HUNGRY DEVICES SUCH AS DC OR STEPPER MOTORS ;In HCS12 MCU module RAM address is from $1000-3FFF ;We use RAM addresses starting at $1000 for scratch pad (variables) and $3FFF for Stack ;Modified from an example from Chapter 4 of HCS12 textbook by Mazidi & Causey ;Written and tested by Mazidi ;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 'mc9s12dt256.inc' ;CPU used by DT256 Axiom MCU Module, Modify it for C128 or XDT512 Module ;----------------------USE $1000-$2FFF for Scratch Pad R1 EQU $1001 R2 EQU $1002 R3 EQU $1003 ;code section ORG $4000 ;Flash ROM address Entry: LDS #$4000 ;Stack LDAA #$F0 STAA DDRB ;PB7-PB4 output ;-------Toggling LEDs on PB7-PB4 of PORTB BACK LDAA #%01010000 STAA PORTB ;Store A into PORTB JSR DELAY LDAA #%10100000 STAA PORTB JSR DELAY BRA BACK ;----------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 Axiom board works with XTAL=4MHz ;Freq. for Instruction Clock Cycle is 2MHz (1/2 of 4MHz). ;(1/2MHz) x 10 Clk x 100 x 20 = 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