XDEF Entry ; export 'Entry' symbol ABSENTRY Entry ; for absolute assembly: mark this as application entry point INCLUDE 'mc9s12c128.inc' BD9600 EQU 2000000/(16*9600) ORG $400 FlashRate DS.B 1 ORG $4000 Entry: LDS #$1000 BSET DDRT,%10000000 ;Make PT7 output (LED connected there) MOVB #1,FlashRate MOVW #BD9600,SCIBDH ;Set serial port for 9600 Baud MOVB #%00010011,SCICR1 ;9 bits, Odd parity, 1 stop bit ;Note: 9th bit is odd parity bit and so ; there are only 8 data bits per character. MOVB #%00100100,SCICR2 ;Enable SCI receiver and receive interrupts CLI KEEPGOING: BSET PTT,%10000000 JSR VARDELAYSUB BCLR PTT,%10000000 JSR VARDELAYSUB BRA KEEPGOING VARDELAYSUB: PSHX ;This subroutine delays for the number of seconds stored PSHY ;in RAM location "FlashRate" PSHA LDAA FlashRate VARDELAY: LDX #16 OUTERLOOP: LDY #$3FFF INNERLOOP: DEY BNE INNERLOOP DEX BNE OUTERLOOP DECA BNE VARDELAY PULA PULY PULX RTS SCI_ISR: BRCLR SCISR1,%00100000,SCI_ISR ;Hang here if RDRF flag is not set LDAA SCIDRL ;This loads received value and also CLEARS RDRF flag! ANDA #%00001111 ;Mask out digit value assuming 1 - 9 key is pressed STAA FlashRate RTI ORG $FFFE DC.W Entry ; Reset Vector ORG $FFD6 DC.W SCI_ISR