Here is some routines for a software implementation of RS-232 for the 68705 HMOS parts. I use them all the time for the P3. I have gotten a lot of requests for this stuff so I thought I'd post it. * MC68705P3 equates: porta equ $00 portb equ $01 portc equ $02 ddra equ $04 ddrb equ $05 ddrc equ $06 tdr equ $08 tcr equ $09 progcr equ $0B ram equ $10 zpagerom equ $80 rom equ $100 mor equ $784 vectors equ $7F8 maskopt equ $2B ;Or whatever ************************************************************** * ram equates for use by the three RS-232 routines * ************************************************************** char equ $10 count equ $11 tempx equ $12 atemp equ $13 xtemp equ $14 baud equ $15 org rom init lda #$FF sta portc lda #%11111101 ;pc0=txd, pc1=rxd sta ddrc ************************************************************** * Slightly modified version of the RS-232 routines in the * * M6805 HMOS and M146805 CMOS Family Users Manual from * * Motorola, M6805UM/AD3, pages 38-40. Main differences are * * that the baud rate is not selected by dip switches and the * * addition of 600 and 2400 baud. Needed 2400 for caller ID! * * Also, txd and rxd are on pc0 and pc1 rather than pc3 and * * pc2 respectively. * * * * Modified by Steve Chandler ste...@halcyon.com * ************************************************************** ************************************************************** * Because of the software timing loops used in the RS-232 * * routines, a 3.579545 MHz crystal must be used. The timing * * is for HMOS and will not work with MC68C05 parts. The * * timing in all three routines below is very critical, so do * * not change ANYTHING no matter how strange the routines may * * seem to be written. And be sure to turn off interupts * * before any calls to or ! * ************************************************************** ************************************************************** * Select the baud rate by deleting the apropriate asterisk. * ************************************************************** * clra ;300 baud * lda #1 ;600 baud * lda #2 ;1200 baud * lda #3 ;2400 baud * lda #4 ;4800 baud * lda #5 ;9600 baud sta baud ************************************************************** * Put your stuff below. * ************************************************************** ************************************************************** * Returns with byte in accumulator from the "serial port" * * port c bit 1. WARNING! This routine will hang forever or * * until a byte is recieved! * ************************************************************** getc stx tempx lda #8 sta count getc4 brset 1,portc,getc4 lda baud and #%111 tax ldx delays,x getc3 lda #4 getc2 nop deca bne getc2 tstx bset 1,portc decx bne getc3 brset 1,portc,getc4 ;false start bit tst ,x tst ,x tst ,x getc7 bsr delay brclr 1,portc,getc6 getc6 tst ,x ror char dec count bne getc7 bsr delay lda char ldx tempx rts ************************************************************** * Sends the byte in the accumulator out the "serial port" * * port c bit 0. * ************************************************************** putc sta char sta atemp stx xtemp lda #9 sta count clrx clc bra putc2 putc5 ror char putc2 bcc putc3 bset 0,portc bra putc4 putc3 bclr 0,portc bra putc4 putc4 jsr delay,x dec count bne putc5 bset 1,portc bset 0,portc bsr delay ldx xtemp lda atemp rts ************************************************************** * Delay routine used by and * ************************************************************** delay lda baud and #%111 tax ldx delays,x lda #$F8 del3 add #$09 del2 deca bne del2 tstx bset 1,portc decx bne del3 rts ************************************************************** * Delay table for selecting baud rate. Do NOT put in page * * zero rom or timing will be not be right! * ************************************************************** delays fcb 32 ;300 baud fcb 16 ;600 baud fcb 8 ;1200 baud fcb 4 ;2400 baud fcb 2 ;4800 baud fcb 1 ;9600 baud org mor fcb maskopt org vectors fdb init ;Timer fdb init ;External fdb init ;SWI fdb init ;Reset