;Getting data from 8 DIP SW of PORTB and sending it 8 LEDs on PORTA ;with HCS12 MCU Module from Axiom using Freescale Student Project board ;HCS12 MCU Modules come with USB-BDM. This code is for CodeWarrior IDE ;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 ;The lower 4 bits of PA3-PA0 are connected to LEDs(LED1-LED4 on J10) permanently ;and must be enabled by clearing bit P4 of PORTP. Also set the LED jumper on UFEA jumpers next to Buzzer ;We also need to connect 4 wires from LED5-LED8 (J10) to pins PA7-PA4 via J6 connector ;See Toggling PORTA sample code for Student project Board on this website. ;On Project Board, ;a)We need to connect 8 wires from SW1-1,2,3,3 and SW2-1,2,3,4 (on J10) to pins PORTB7-PORTB0 (via J6 connector) ;b)Notice on J6 of project Board PORTB7-PORTB0 are pins 41,43,45,47,49,51,53,55 ;On HCS12 MCU Module itself, ;a)MAKE SURE ALL the jumpers for PORTB are removed.(SW3-1...SW3-4 and LED1-LED4) ;b)The 8 Jumpers (SW3-1...SW3-4 and LED1-LED4) on HCS12 MCU module connect the PORTB to SW and LEDs of the Module itself. ;c)The PORTB can be either used by the HCS12 MCU Module itself or the Project Board, but not both of them at the same time. ;Written and tested by M. Mazidi from examples in Chap.4 of HCS12 textbook by Mazidi & Causey. ;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 'mc9s12dt256.inc' ;CPU used by Axiom board ;----------------------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 #$FF STAA DDRA ;Make PA7-PA0 as output BSET DDRP, %00010000 ;the lower 4 bits of PA3-PA0 are connected to LEDs(LED1-LED4) permanently BCLR PTP, %00010000 ; and must be enabled by clearing bit P4 of PORTP ;We need connect 4 wires from LED5-LED8 to pins PA4-PA7 via J6 connector LDAA #$0 STAA DDRB ;Make PB7-PB0 as input ;We need connect 8 wires from SW1-1,2,3,3 and SW2-1,2,3,4 (on J10) to pins PB7-PB0 via J6 connector ;-------Get data from DIP SW of PORTB and send it LEDs on PA7-PA0 of PORTA BACK LDAA PORTB ;Get data from PORTB STAA PORTA ;and send it to PORTA 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 x10x200=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