Google Answers Logo
View Question
 
Q: Changing parallel port mode from an application (using C) ( Answered,   1 Comment )
Question  
Subject: Changing parallel port mode from an application (using C)
Category: Computers > Programming
Asked by: lazybee-ga
List Price: $10.00
Posted: 31 Aug 2002 08:50 PDT
Expires: 30 Sep 2002 08:50 PDT
Question ID: 60499
I need to set parallel port mode through my application. I want to set
it to ECP. Need the source code in C to do that. Embedded assembly is
ok.

Clarification of Question by lazybee-ga on 31 Aug 2002 09:02 PDT
Parallel port in ECP mode requires DMA settings. Code must include
those settings too.
Thanks.
Answer  
Subject: Re: Changing parallel port mode from an application (using C)
Answered By: maniac-ga on 03 Sep 2002 18:27 PDT
 
Hello lazybee,

I can't be sure of the constraints on your application, I am guessing
DOS or an embedded system instead of Linux or Windows. If not, you
should ask for clarification if the following links don't answer your
question. In particular, your BIOS or operating system drivers may
have settings for both ECP and DMA settings that may be simpler than
the solutions I refer to below. Be sure to mention the system and OS
in a request for clarification if needed.

Perhaps the best summary to the "Standard Parallel Port" is at...
  http://www.beyondlogic.org/spp/parallel.htm

which starts with some general information but includes the port
addresses, bit assignments (including the DMA bit), and has sample C
code that accesses the various port addresses.

Additional information on ECP settings is at...
  http://www.beyondlogic.org/ecp/ecp.htm

which includes the settings for the ECP configuration words (e.g., IRQ
setting, DMA channels used).

A site that has several good links is "The PC's Parallel Port" at...
  http://www.lvr.com/parport.htm

I checked a number of references it provided and they appear to have
good information.

If you need specific information on how to program the DMA, I will
definitely need more information. You generally set the base address,
length, and then enable the DMA - but there are specifics for each
kind of DMA. You may also need to run benchmarks. In a real time
system I am familiar with, DMA is faster than PIO for data transfers
of 12 bytes or more, and a busy wait for DMA complete is faster than
the task switching overhead.

If you want to search more on your own, search phrases that can help
find additional information include...
  "source code" "parallel port settings"
  "source code" +DMA

Include phrases such as the operating system name and part name /
number for the DMA to restrict answers to your specific situation.
  --Maniac

Request for Answer Clarification by lazybee-ga on 04 Sep 2002 07:24 PDT
Hi Maniac,

Thanks for reponding. Your assumption that I am working on a DOS based
system is correct.

My application is DOS based and it needs to have parallel port set to
ECP. My application needs to do this whenever it initializes. I do not
care about prior settings of the parallel port. I just need to know:
"Set memory address 0xnnnn to 0xmmmm" and this will set my parallel
port mode to ECP. I need to know values for 0xnnnn and 0xmmmm.

I have already gone through the links you've provided. But none of
those links talk about "Set memory address 0xnnnn to 0xmmmm" to set
parallel port mode to ECP or whatever. Yes, links at beyondlogic talk
about further modes under ECP defined in  Extended Control Register
(ECR) but ECR at address BASE+0x402h is available when parallel port
is set to ECP. I want to know how to set it to ECP.

I hope this clarifies the question. 

Thanks again.

Clarification of Answer by maniac-ga on 04 Sep 2002 18:38 PDT
Hello lazybee,

To answer your clarification request, let me break it into parts with
reference to the links provided and providing an additional reference.
This appears to be best set by the BIOS, but I'm providing a couple
alternatives that should work with your own code.

The link 
  http://www.beyondlogic.org/spp/parallel.htm
in the section titled "Parallel Port Modes in BIOS" indicates that you
normally enable ECP in the BIOS. It also indicates that the software
can change these settings by writing to configuration registers at
0x2FA, 0x3F0, 0x3F1, etc. but that this is not portable since there is
no standard for these registers. A quick look at a few other sites
appears to confirm this assessment.

At this point, you probably need specific vendor documentation to
determine which address to change and the bits to be set. A search
using google with phrases such as
  +ecp +bios +3f0 +"configuration register"
turns up a set of PDF files that may help.

Another alternative is to download a recent Linux kernel and look in
the parport code for chip detection and various settings. For an idea
of the code and how it works, look at
  http://home.t-online.de/home/gunther.mayer/gmpatch-2399p6-superio_4a
which is a patch for a kernel version just prior to the 2.4 release.
There are also BIOS replacements such as...
  Open BIOS
  http://www.freiburg.linux.de/OpenBIOS/
  Linux BIOS
  http://www.linuxbios.org/
which may have relevant code as well.

As another option, if you have a restricted set of equipment to work
with, what you could do is...
 - clear the ECP setting in the BIOS, and read the range of addresses
for the configuration registers to determine the "not set" condition.
 - set the ECP setting in the BIOS, and read the same configuration
registers to determine the "set" condition.

That would give you the settings for the particular motherboard and
chip combinations that your equipment uses. If the BIOS gets out of
configuration, you could then have the software "make it right" by
reading the existing value, making the changes noted above, and then
rewriting those values.

I hope one of these techniques provides the data you need (specific
address and value settings). If not, let me know and I will dig some
more on this question.
  --Maniac
Comments  
Subject: Re: Changing parallel port mode from an application (using C)
From: bribold-ga on 04 Sep 2002 15:42 PDT
 
Hi Lazybee

it's all at:

http://www.fapo.com/ecpmode.htm

It's got everything from signal sequences to registers and bit tables.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy