Jump to content
IGNORED

RS232 Programming


9640News

Recommended Posts

I seem to have this RTS/CTS thing working however to make it work I had to make CTS logic high to hold of the PC from sending. I thought it would the reverse. (?)

 

Here is the code primitive that checks for a key and leaves in R4 (TOS cache) if it finds one.

(in RPN assembler of course) :)

 

Configuration is held in variables:

CARD contains >1300 

UART contains CARD+>40   (or >80 for RS232/2)

CODE: CKEY? ( -- n )          \  "com-key"
         0 LIMI,
         R12 RPUSH,           \ save R12 on return stack
         CARD @@ R12 MOV,
         5 SBZ,               \ CTS line LOW. You are clear to send
         TOS PUSH,            \ give us a new TOS register (R4)
         TOS CLR,             \ erase it
         UART @@ R12 MOV,     \ select >1340 CRU address
         21 TB,               \ test if char ready
         EQ IF,
             TOS 8 STCR,      \ read the char
             18 SBZ,          \ reset 9902 rcv buffer
             CARD @@ R12 MOV,
             5 SBO,           \ CTS line HI. I am busy!
             TOS SWPB,        \ shift to other byte
         ENDIF,
         R12 RPOP,            \ restore old R12
         2 LIMI,
         NEXT,
         END-CODE

For the curious...

This primitive routine is then used in the Forth kernel to make the "keyword"  KEY which waits for a key (forever) and returns it if CKEY? returns a non-zero

: KEY       ( -- char)
            BEGIN
              PAUSE        \ multi-tasking switch
              CKEY?        \ test for key
              ?DUP         \ dup if not zero
            UNTIL          \ loop until not zero on stack
            83D6 OFF ;     \ reset VDP screen timeout

Now when I paste source code into Tera term it stops at the end of a line automagically until the compiler has digested the code and then continues.

Before I had to put a 300ms delay in Teraterm to prevent over-running the Forth compiler.

I still need a 1mS delay between characters because Forth echoes each character back and without a receive interrupt I can't do duplex but it's better than it was.

 

I am pleased.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...