;Displaying ATD0 channel 5 on LEDs of PORTB for Dragon12+ Trainer Board ;with HCS12 Serial Monitor Program installed. This code is for CodeWarrior IDE ;Modified from Program 13-1 of HCS12 book by Mazidi & Causey ;In Dragon12+ PLL=48MHz. 48MHz/2=24MHz, Divivde by 24 to get 1MHz for conversion freq. ;ADC channel 5 (PAD5) is connected to Temp Sensor (U14A close to blue POT) ;Slowly warm up (or touch) Temp Sensor to see changes on LEDs of PORTB. NOT TOO HOT or the board will be damaged ABSENTRY Entry ; for absolute assembly: mark this as application entry point ; Include derivative-specific definitions INCLUDE 'mc9s12dp256.inc' ;CPU used by Dragon12+ board ;----------------------USE $1000-$2FFF for Scratch Pad R1 EQU $1001 R2 EQU $1002 R3 EQU $1003 ;code section ORG $4000 ;Flash ROM address for Dragon12+ Entry: LDS #$4000 ;Stack LDAA #$FF STAA DDRB ;Make PORTB output ;PTJ1 controls the LEDs connected to PORTB (For Dragon12+ ONLY) LDAA #$FF STAA DDRJ ;Make PORTJ output, (Needed by Dragon12+) LDAA #$0 STAA PTJ ;Turn off PTJ1 to allow the LEDs on PORTB to show data (Needed by Dragon12+) ; ;-------Get data fron Chan 5 of ATD0 and put it on PORTB MOVB #$80,ATD0CTL2 JSR DELAY MOVB #$08,ATD0CTL3 MOVB #$EB,ATD0CTL4 ;8-bit resolu, 16-clock for 2nd phase, ;prescaler of 24 for Conversion Freq=1MHz H1 MOVB #$85,ATD0CTL5 ;Chan 5 of ATD0 H2 BRCLR ATD0STAT0,$80,H2 LDAA ATD0DR0L STAA PORTB JSR DELAY ;Optional BRA H1 ;Keep reading the ADC ;----------DELAY DELAY PSHA ;Save Reg A on Stack LDAA #1 STAA R3 ;--0.1 msec delay. The Serial Monitor works at speed of 48MHz with XTAL=8MHz on Dragon12+ board ;Freq. for Instruction Clock Cycle is 24MHz (1/2 of 48Mhz). ;(1/24MHz) x 10 Clk x240x1=0.1 msec. Overheads are excluded in this calculation. L3 LDAA #1 STAA R2 L2 LDAA #240 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