Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

uart interrupt tx rx in Dos32 bit open watcom (Developers)

posted by maui, 19.11.2013, 12:42

> > > Thanks for your time on this topic.
> > after looking a while on it it *looks* ok
> >
> > however the sender code is missing. therefore a few questions:
> >
> > is the fifo empty when it stops?
> > is there some correlation to (index & 0x0f) ?
> >
> > when transmission stops because no more data to be send,
> > how do you restart transmission?
> >
> > is this a PCI bus machine, or some *real* old machine ?
> >
> > lastly: what purpose has the rmloop ?
>
> I found it necessary to prime the transmit buffer. I assume a standard AT
> style serial port.
>
> Excerpt from the code linked to:
>
> _WRCOM1Q LABEL FAR
> ; WRITE A STRING TO THE COM1 QUEUE AND SEND USING INTERRUPTS.
> PUSH BP
> MOV BP,SP
> PUSH DS ; PUSH DS.
> PUSH ES
> PUSH CX
> PUSH DX
> PUSH SI
> PUSH DI
> MOV CX,WORD PTR SS:[BP+CHARS] ; GET NUMBER OF BYTES.
> LES SI,DWORD PTR SS:[BP+STRING] ; GET ADDRESS OF BUFFER.
> MOV AX,CMWRT1Q ; GET COM1 TRANSMIT COMMON BLOCK.
> MOV DS,AX
> MOV DX,MDCNTL
> MOV AL,OUT2 OR RTS OR DTR ; ENABLE DATA TERMINAL READY AND READY TO SEND
> OUT DX,AL
> ; IS THE QUEUE EMPTY?
> CLI ; DISABLE INTERRUPTS WHILE CHECKING QUEUE SIZE.
> MOV DI,DS:[WRTQSPACE] ; GET WRITE QUEUE INDICATOR.
> CMP DI,WRTQSIZ ; IS IT EMPTY?
> JNE QUEDTA
> ; THE TRANSMIT BUFFER IS EMPTY AND MUST BE "PRIMED" BY SENDING OUT THE
> FIRST BYTE.
> ; CHECK THAT THE PHYSICAL TX BUFFER IS EMPTY.
> MOV DX,LNSTAT ; WAIT TILL ITS GONE.
> TXTST3 LABEL NEAR ; TRANSMIT FINISH LOOP.
> IN AL,DX ; GET LINE STATUS.
> AND AL,TXEMTY
> JZ TXTST3 ; LOOP UNITL NON-ZERO.
> MOV DX,MDCNTL
> MOV AL,OUT2 OR RTS OR DTR ; ENABLE DATA TERMINAL READY AND REQUEST TO
> SEND
> OUT DX,AL
> MOV DX,LNCNTL ; SET TO LINE CONTROL.
> IN AL,DX ; GET THE VALUE.
> MOV AH,AL ; SAVE ORIGINAL VALUE.
> AND AL,NOT SETBAUD ; AND OFF THE SET BAUD BIT.
> OUT DX,AL ; SEND IT.
> MOV AL,ES:[SI] ; GET THE FIRST BYTE TO SEND.
> INC SI ; POINT TO THE NEXT BYTE.
> MOV DX,DATABF ; SEND THE FIRST BYTE TO THE DATA PORT.
> OUT DX,AL
> MOV AL,AH ; RESTORE LINE CONTROL.
> MOV DX,LNCNTL
> OUT DX,AL ; BACK IT GOES.
> DEC CX ; DECREMENT THE COUNT.
> MOV AX,DI ; IF NEXT BRANCH OCCURS, ALL SPACE IS AVAILABLE.
> CMP CX,0 ; DID WE ONLY HAVE TO SEND ONE BYTE?
> STI ; ENABLE INTERRUPTS.
> JE TXDONE ; WAHOO!
> QUEDTA LABEL NEAR
> STI ; ENABLE INTERRUPTS
> NOP
> MOV AX,DS:[WRTQSPACE] ; DO WE HAVE SPACE ON THE QUEUE?
> CLI ; DISABLE INTERRUPTS TO UPDATE QSPACE.
> CMP AX,0
> JE QUEDTA ; WAIT FOR SOME SPACE TO CLEAR UP.
> DEC AX ; UPDATE AVAILABLE QUEUE SPACE, PREVENT INTERRUPT HANDLER FROM
>
> MOV DS:[WRTQSPACE],AX ; MODIFYING IT AT THE SAME TIME
> STI ; ENABLE INTERRUPTS.
> MOV DI,DS:[WRTHEAD] ; GET THE HEAD OF THE QUEUE.
> MOV AL,ES:[SI] ; GET NEXT BYTE TO QUEUE UP.
> INC SI ; POINT TO NEXT BYTE
> MOV DS:[DI+WRTQUE],AL ; PUT IT ON THE QUEUE.
> INC DI ; POINT TO NEXT SPOT IN QUEUE
> CMP DI,WRTQSIZ
> JNE HEADINC
> XOR DI,DI ; RESET IT TO ZERO.
> HEADINC LABEL NEAR
> MOV DS:[WRTHEAD],DI
> LOOP QUEDTA
> MOV AX,DS:[WRTQSPACE]
> TXDONE LABEL NEAR
> POP DI
> POP SI
> POP DX
> POP CX
> POP ES
> POP DS
> POP BP
> RET ; RETURN

Hi,

sorry for the delay in the reply, I'm trying to understand your code, to make it work with mine.
Your code is checking for if the transmitter buffer has space to send the new data right?
When I trying it, I get from the register status line, that the Empty Transmitter Holding Register is up, but after I put another byte in queue, the bit turns off, returning at that point, doesn't not always come in the getting a next call from the byte sent.
To implement the interrupt, I have to use 2 block of code, one for protect mode, and another one for real mode, the code i posted before, was the real mode, the tx interrupt has never entered the protect mode.

I'm trying to understand, if there is a way to keep loading byte in the fifo, till the queue is full, then clearing the interrupt and return, so wait for the next call.

Thanks again for your support.

maui.

 

Complete thread:

Back to the forum
Board view  Mix view
22762 Postings in 2122 Threads, 402 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum