;Name:  Derek Marston and Pete Susi
;Date:   3/07/03
;Desc:  This program will send a Free Token serially on the TxD pin


RAM             EQU     800h;
FLASH           EQU     8000h;
StatusReg       EQU     00C4h;
DataReg         EQU     00C7h;
ControlReg1     EQU     00C2h;
ControlReg2     EQU     00C3h;
BaudRateReg     EQU     00C1h;
SCIvector       EQU     0FFD6h;
PortA           EQU     0000h;
DirA            EQU     0002h;

;******************************************************

                                                       

     
     org        FLASH
main:
;     ldaa #0FFh;
;     staa DirA;
;     staa PortA;

     bsr        ConfigPort;


;     cli                        ; ENABLE the interrupts (Doofus)

loop:
     bsr        SendFreeToken;
     bra        loop;


;******************************************************
;Name:          ConfigPort
;Input:         None
;Output:        None
;Destroys:      A
;Description:   Configures port for:
;               Asyncronous serial data
;               8 bit data, no parity, 1 stop bit
;               enable transmitter and receiever

ConfigPort:
     ldaa       #00100000q      ; no loopback
     staa       ControlReg1;
     ldaa       #00101100q      ; enable transmitter and receiver (and RIE)
     staa       ControlReg2

     ldaa       #20h            ; BR divisor
     staa       BaudRateReg

     rts;

;******************************************************
;Name:          TransmitA
;Input:         A = the byte to transmit
;Output:        None
;Destroys:      X
;Description:   Wait until the transmitter is ready (wait until the
;		TDRE bit in the Status Register is 1), then
;		write the contents of A to the Data register.
TransmitA:
      ldx       #StatusReg      ; get status flags
      ldab       StatusReg
      andb       #10000000q     ; Check for ready
      beq        TransmitA      ; Wait until ready

      staa      DataReg
      rts;

;******************************************************
;Name:		SendFreeToken
;Input:		none.
;Output:	none.
;Destroys:	A, flags
;Description:	Send one free token

SendFreeToken:

	ldaa	#0AAh
	jsr	TransmitA
	ldaa	#0FFh
	jsr	TransmitA
	ldaa	#0AAh
	jsr	TransmitA
	rts


;******************************************************
;Name ReceiveInterrupt
;Input: none
;Output: none
;Destroys: A
;Desc: shows on PortA that a byte has been recieved

ReceiveInterrupt:

    nop

    rti

;******************************************************
;Name:		InstallInterruptVector
;  NOT A ROUTINE
;
;InstallInterruptVector:

        org SCIvector           ; address for jump vec: FFD6h

SCIVec:  DW      ReceiveInterrupt

;******************************************************
