Newsgroups: comp.robotics
Path: brunix!news.Brown.EDU!agate!howland.reston.ans.net!math.ohio-state.edu!cyber2.cyberstore.ca!nntp.cs.ubc.ca!newsserver.sfu.ca!sfu.ca!robertj
From: robertj@malibu.sfu.ca (Robert John Johnson)
Subject: 6811 SCI
Message-ID: <robertj.753312659@sfu.ca>
Sender: news@sfu.ca
Organization: Simon Fraser University, Burnaby, B.C., Canada
Date: Sun, 14 Nov 1993 21:30:59 GMT
Lines: 77

Hello:
A few days ago, I posted a message asking for help with a 6811 SCI.  
I got some responses, but they thought I was vague, so here is more.
I am using:        68HC811E2
                   Single Chip Mode
                   8MHz crystal (2MHz clock)

When I set the SCI up to transmit at 9600 BAUD it appears to be sending a lot
faster.

Included below is my test code.  I hope this will help.

Robert Johnson
(robertj@sfu.ca)



        include "a:\equ.h"      ;6811 register definitions
        org $FF80

***************************************************************************
*       Subroutine:  setup_sci
*
*       Purpose:  to set up bi-directional serial communications from the
* 6811 SCI.  Crystal frequency is assumed to be 8.0MHz.  Baud rate is
* specifed in accumulator A.
*
*       Parameters:  baud rate is in accumulator A.
***************************************************************************
setup_sci       staa baud       ;set baud rate
                ldaa #$00       ;set up control regesters with rx and tx enabled
                staa sccr1      ;8 data bits
                ldaa #$0C
                staa sccr2
                rts

***************************************************************************
*       Subroutine:  send_sci
*
*       Purpose:  to send a byte out of the sci transmitter.  Subroutine
* wait if transmitter is currently in use.
*
*       Parameters:  byte to be sent is in accumulator B.
***************************************************************************
send_sci        psha
send_sci_loop   ldaa scsr               ;loop until send buffer is empty
                bita #$80
                beq send_sci_loop
                stab scdr
                pula
                rts

***************************************************************************
*       Baud rate defines
***************************************************************************
BAUD_9600       equ     $30
BAUD_4800       equ     $31
BAUD_2400       equ     $32
BAUD_1200       equ     $33
BAUD_600        equ     $34
BAUD_300        equ     $35
BAUD_150        equ     $36
BAUD_75         equ     $37

***************** MAIN LOOP USED FOR TESTING *******************************
        org $F800
main    ldaa BAUD_9600  ;setup sci
        jsr setup_sci
        ldab #$61
loop    jsr send_sci    ;repeatedly send 'a'
        bra loop

        
        
***************** RESET VECTOR *********************************************
        org $FFFE
RESET   FDB $F800
