From: dejesus@eniac.seas.upenn.edu (Cavalier)
Subject: Help needed
Organization: University of Pennsylvania
Lines: 128
Nntp-Posting-Host: eniac.seas.upenn.edu

Hello.  I hope somebody out here can help me.  I am currently working
on a project where I am trying to communicate from an IBM 386 with
Phoenix BIOS, using C++, to a board that I made with an Intel 8085 CPU
with UART chip.  The board works fine with the TRANSMIT command and 
Terminal Emulation mode of Kermit, but there seems to be something wrong
with the initialization or protocol used when I try C++.  I need to
access the unit I built using C, because I have a sizable chunk of C
code that I will be using to perform calculations and operations that
will be very difficult to code in assembly language for the 8085.

I have included the assembly code that I am running and the C++ code
that I am trying to use.  If anyone can show me something that I
am doing blatantly incorrectly or that I am missing because of my lack
of knowledge about RS-232 serial communications, please e-mail me.
I wrote the assembly language to wait for a character to be received and
then to check it against the 0x20 character, if a 0x20 is received, 
the LEDs will indicate this.  Two C++ programs that I have written do
nothing, but set up COM port 2 and send the 0x20 character.  One uses
the bioscom() function in bios.h the other uses the software interrupt
int86() function in dos.h.  I have triple checked the baud rate ( 2400 )
the parity ( none ) the stop bits ( 1 ) the character length ( 8 bits )
and the interrupt calls for ( 0x14 ).  Currently, I am at a loss as
to what may be wrong.  Any hardware gurus out there want to comment?


						Thanks alot,
						Hubert De Jesus
						dejesus@eniac.seas.upenn.edu


  				INTEL ASM

COMMAND     EQU     3000H                ;Command Register on 8155
PORTA       EQU     3001H                ;Port A on 8155
TIMERLO     EQU     3004H                ;High 8 bits of 8155 Timer
TIMERHI     EQU     3005H                ;Low 8 bits of 8155 Timer
UARTDATA    EQU     E000H                ;UART Data Register
UARTCMD     EQU     E001H                ;UART Command Register

            ORG     4000H                ;SRAM location
	    MVI     A,08H		 ;Set Low Timer Bits
            STA     TIMERLO
            MVI     A,40H		 ;Set High Timer Bits
            STA     TIMERHI
            MVI     A,11111101B          ;Start Timer & Enable Port A
            STA     COMMAND

            MVI     A,11H                ;Display 11 on 7-segment LEDs
            STA     PORTA

            MVI     A,00H		 ;Clear UART Command
            STA     UARTCMD
            STA     UARTCMD
            STA     UARTCMD
            MVI     A,01000000B		 ;Internally reset UART 
            STA     UARTCMD
	    LDA     UARTDATA             ;Remove extraneous data
 	    MVI     A,01001111B          ;Init UART for 8 data bits,
            STA     UARTCMD              ;  no parity, 1 stop bit, 64x async
            MVI     A,00100111B          ;Enable Transmit and Receive
            STA     UARTCMD

INIT:       LDA     UARTCMD		 ;Read Status Register
            ANI     02H                  ;Is RxRDY?
            JZ      INIT                 ;No, loop

            LDA     UARTDATA             ;Read Data Character
            CPI     ' '                  ;Is Character = 0x20?
            JNZ     INIT                 ;No, loop
     
            MVI     A,22H                ;Character received, 
            STA     PORTA                ;  Display 22 on 7-segment LEDs
            HLT
            END

                              C++ using BIOSCOM()

#include <stdio.h>
#include <stdlib.h>
#include <bios.h>

#define INIT          0
#define SEND          1
#define RECEIVE       2
#define STATUS        3

#define COM2          1

void
main()
{
   char abyte;

   abyte = 0xa3;
   bioscom( INIT, abyte, COM2 );
   printf( "Initialized COMM PORT 2\n" );

   while( !( bioscom( STATUS, 0, COM2 ) & 0x4000 ) )
     ;
   abyte = ' ';
   bioscom( SEND, abyte, COM2 );
   printf( "Sent start character\n" );
}


        			C++ using INT86()

#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <bios.h>

main()
{
   union REGS registers;
  
   registers.h.ah = 0x00;
   registers.h.al = 0xa7; 
   registers.x.dx = 0x01;
   int86( 0x14, &registers, &registers );
   printf( "COM2 Initialized\n" );
 
   registers.h.ah = 0x01;
   registers.h.al = 0x20;
   registers.x.dx = 0x01;
   int86( 0x14, &registers, &registers );
   printf( "Sent start character\n" );
 }
