z80180 ASCI channel 1 help

I am writing code in assembler to read data from a Palm to a z80180. The communication is done by polling the status of channel 1. I can recieve one character but not a whole string. In order to recieve a second character I have to interrupt the communication and start over. Both Palm and z80180 are set at 9600 baud 8 bits 1 stop no parity. Here is a snippet that is working: ..GetcLoop REFRESH_WATCHDOG IN0_A STAT1 bit RDRF, a jr z, ..GetcLoop IN0_A RDR1 ld (RecBuffer), a

Reply to
Carol
Loading thread data ...

.>Here is a snippet that is working:

I think we need to see the code that isn't working to be able to help you out.

Reply to
Gary Kato

On 19 Aug 2004 08:56:12 -0700, Carol wrote: : I am writing code in assembler to read data from a Palm to a z80180. : The communication is done by polling the status of channel 1. I can : recieve one character but not a whole string. In order to recieve a : second character I have to interrupt the communication and start over. : Both Palm and z80180 are set at 9600 baud 8 bits 1 stop no parity.

You're _absolutely_ certain the ASCI isn't signaling a parity or framing error? IMNSHO this code is not ready for prime time :(

Reply to
Howard Goldstein

No experience with Palm's idiosynchracies. I run UARTs on Z180's in an interrupt driven manner. The head of my ASCI1 service routine looks like (many non-Rx parts elided):

CHECK_RECEIVER: IN0 B,(Z180_STAT1) ;get status of ASCI channel 1

IN0 A,(Z180_CNTLA1) ;get current ASCI channel 1 control A AND not CNTLA1_EFRn ;reset errors associated with reception OUT0 (Z180_CNTLA1),A ;update ASCI channel 1 control register A

LD A,B ;copy status of ASCI channel 1 into r.a AND {STAT1_RDRF or STAT1_RIE} ;isolate receiver status CP {STAT1_RDRF or STAT1_RIE} ;check received data ready JR Z,SERVICE_RECEIVER ;received data available

... RET

SERVICE_RECEIVER: LD D,B ;move status of ASCI channel 1 into r.d

IN0 C,(Z180_RDR1) ;get received character datum into r.c LD B,ERROR_FREE ;initialize character modifier

LD A,D ;copy status of ASCI channel 1 into r.a TST STAT1_OVRN ;check if overrun error detected JR Z,CHECK_FRAMING ;absence of overrun error

LD A,B ;get state of character modifier OR ERROR_OVERRUN ;mark character as having overrun error LD B,A ;update state of character modifier

CHECK_FRAMING: LD A,D ;copy status of ASCI channel 1 into r.a TST STAT1_FE ;check if framing error detected JP Z,CHECK_PARITY ;absence of framing error

LD A,B ;get state of character modifier OR ERROR_FRAMING ;mark character as having framing error LD B,A ;update state of character modifier

LD A,00000000b ;break indicated by continuous spacing CP C ;check if break detected JR NZ,CHECK_PARITY ;framing error not caused by a break

LD A,(ASCI1_EXCEPTION) ;get exception handling flags for asci 1 TST IGNORE_BREAK ;check if break should be ignored JP NZ,RECEIVE_DONE ;ignore detected break character

... input throttling, break handling, driver signalling

IN0 A,(Z180_STAT1) ;get current ASCI channel 1 status OR {STAT1_TIE or STAT1_RIE};(Rx interrupt for XON/XOFF flow!) OUT0 (Z180_STAT1),A ;update ASCI channel 1 status register

JP RECEIVE_DONE ;break character processing complete

...

RECEIVE_DONE: JP CHECK_RECEIVER

Note that my ISR does considerably more than just pulling Rx characters out of the receive FIFO so keep that in mind when deciding how much of it to *ignore*! Note, also, that I delay processing all errors in the data by buffering "error flags" alongside the received data and passing them to the driver for handling (e.g., the various ERROR_* flags in the "character modifier"). But, hopefully, this will give you an idea of how to look at what is happening in the receiver. Trace through the cases where "no data available" (recall, *I* may have been interrupted for a Tx event!) as well as "Rx data available" and associated Rx errors.

HTH,

--don

N.B. Incoming mail is unconditionally and silently discarded.

Reply to
Don

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.