;************************************************************** ;* This stationery serves as the framework for a * ;* user application. For a more comprehensive program that * ;* demonstrates the more advanced functionality of this * ;* processor, please see the demonstration applications * ;* located in the examples subdirectory of the * ;* Freescale CodeWarrior for the HC12 Program directory * ;************************************************************** ; Include derivative-specific definitions INCLUDE 'derivative.inc' ; export symbols XDEF Entry,KVS,PRESSED,PRESSED_VAL,PORT_U,SEQUENCE,TON,TOFF,PORT_T,COUNTER XREF __SEG_END_SSTACK,Keypad,PulseWidthMod Variables: Section PRESSED ds.b 1 ;the keypad value in the LUT PRESSED_VAL ds.b 1 ;the numeral of the pressed key or the index of PRESSED in the LUT TON ds.b 1 TOFF ds.b 1 COUNTER ds.b 1 ;"define a byte variable to use as a counter" ^1 Constants: Section DDR_T equ $242 ;DC motor DDR PORT_T equ $240 ;DC motor DDR_U equ $26A PSR_U equ $26D PDR_U equ $26C PORT_U equ $268 ;keypad ;key value pairs from 4.3 KVS dc.b $EB,$77,$7B,$7D,$B7,$BB,$BD,$D7,$DB,$DD,$E7,$ED,$7E,$BE,$DE,$EE ;given sequence from lab instructions (with trailing zero) SEQUENCE dc.b $70,$B0,$D0,$E0,$00 ;================================================================================= Code: Section Entry: LDS #__SEG_END_SSTACK BCLR COUNTER,#$FF;initialize the counter to zero BSET DDR_U,#$F0 ;bits 1-3 in bits 4-7 out BSET PSR_U,#$F0 ;pins 1-3 pull up BSET PDR_U,#$0F ;pull up pins 1-3 MOVB #$80,CRGINT ;enable real-time interrupts MOVB #$3C,RTICTL ;set RTI interval to 1 ms CLI ;enable interrupts Main: JSR Keypad ;"The *unaltered* keypad routine from Lab 5.2 should be called in the main program."