delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/04/07/23:38:42

Date: Fri, 8 Apr 94 12:28:32 CST
From: michaels AT vsl DOT com DOT AU (Michael Snoswell)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: serial port and outportb problems

This may be a GO32 problem, a serial problem or just me :-)

I want to set a COM port's baud rate etc. I only have ASM examples to go
by and I'm not an assembler programmer and haven't done serial port stuff
since my CP/M days. Excuses aside, here's the code:

#include <pc.h>

#define COM1		0x3F8
#define BAUDRATE	19200

main()
{
unsigned short BRDL = (unsigned short)(COM1 + 6);
unsigned short BRDH = (unsigned short)(COM1 + 8);
unsigned short LCR  = (unsigned short)(COM1 + 14);

  outportb(LCR,  0xFF); /* I don't know why */
  outportb(BRDL, (unsigned char)(115200 / BAUDRATE));
  outportb(BRDH, (unsigned char)((115200 / BAUDRATE) >> 8));
  outportb(LCR,  0x03);
  
}


The 0x03 should be n,8,1 but I'm not positive.

Anyway, it compiles, links and runs without error (GO321.11m4) but according
to MSD the COM port settings are unchanged. What am I doing wrong?

Thanks
	Michael Snoswell

--------------------------------------------------------------------------------
Michael Snoswell			michaels AT vsl DOT com DOT au
Vision Systems Limited			+61 8 343 0627
South Australia				"Intelligent, witty quote"

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019