;Displaying Overflow Timer on LEDs of PORTA in Assembly for Project Board with HCS12 MCU module using CodeWarrior ;Modified from Example 9-3 in HCS12 book 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 'mc9s12dp256.inc' ; ;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 #$80 STAA TSCR1 LDAA #$04 ;Prescaler=16 (Try 0-7 values to see changes on LEDs) STAA TSCR2 LDAA #0 OVER BSET TFLG2,%10000000 ;clear the Timer overflow flag (writing HIGH clears it) H1 BRCLR TFLG2,mTFLG2_TOF,H1 ;wait for Timer Overflow INCA ;keep adding the overflows STAA PORTA ;and dump it on PORTA to see BRA OVER ;Notice the LEDs of LED1-LED4 on Project Board are arranged in awkward manner. ;LED1 should have been connected to the PA0 pin of CPU ,but instead it is connected to PA3. ;and that is the reason the counter looks awkward. ;************************************************************** ;* Interrupt Vectors * ;************************************************************** ORG $FFFE DC.W Entry ;Reset Vector. CPU wakes here and it is sent to start of the code at $4000