;Testing Push Button (PB1 and PB2) Switches on Student Project Board. ;This program gets status of Push Button SW of PB1-PB2 and sends it to LEDs on PORTA ;Using HCS12 MCU Module with Freescale Student Project Board ;HCS12 MCU Modules come with USB-BDM and ready to be used with CodeWarrior IDE ;The lower 4 bits of PA3-PA0 (pins of HCS12 CPU) 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 ;The lower 2 bits of PP1-PP0 (pins of HCS12 CPU) are connected to push buttons of PB1 and PB2 permanently ;and must be enabled by clearing bit P5 of PORTP. Also set the PB jumper on UFEA jumpers next to Buzzer ;On HCS12 MCU Module itself ;a)MAKE SURE BOTH jumpers for PP0 and PP1 are removed (SW1 and SW2). ;b)Also Make sure 8 Jumpers (SW3-1 to SW3-4 and LED1-LED4) on HCS12 MCU module are also removed ;Written and tested by M. Mazidi using 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, %00110000 ;Make PP4 and PP5 as output. On the Project Board, a)the lower 4 pins of PA3-PA0 are connected to LEDs(LED1-LED4) BCLR PTP, %00110000 ;and b)the PP0 and PP1 pins are connected to PB1 and PB2 push buttons. c) They mut be enabled by clearing pins P4 and P5 of PORTP ;on Project Board,we need to connect 4 wires from LED5-LED8 (J10) to pins PA4-PA7 via J6 connector (pins 25,27,29,31) ;-------Getting Data from PTP and sending it to PORTA BACK LDAA PTP ANDA #$03 STAA PORTA ;Store A into PORTA ;JSR DELAY ;Optional BRA BACK ;----------DELAY DELAY PSHA ;Save Reg A on Stack LDAA #10 ; STAA R3 ; ;--10 msec delay. The HCS12 MCU Module 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