?
Solved

Port programming....

Posted on 2003-03-26
13
Medium Priority
?
1,706 Views
Last Modified: 2013-11-15
Ok guys.... let's see who gets this one correct first. When I send 0xFF through an external microcontroller to the parallel port, why does my C program (Turbo C++ 3.0, Windows 98) read it as 0x7A??

Awaiting some quick replies.. (comments expected definitely from Kocil, Akshay.... and all other experts).

Mayank.
0
Comment
Question by:Mayank S
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 2
  • 2
  • +2
13 Comments
 

Expert Comment

by:cang24
ID: 8212813
What port addres R U using?
It colud be that some bits are not available, I've been working parallel port and in some address that's the problem, You  have three address and in some cases  there are bits not manage correctly.

Are you writing in 378h???
0
 
LVL 30

Author Comment

by:Mayank S
ID: 8215453
378H is for sending data from the computer to the device.... I am reading from 379H.

Mayank.
0
 
LVL 30

Author Comment

by:Mayank S
ID: 8216034
(Standard for the parallel port, isn't it?)

Mayank.
0
Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

 
LVL 3

Expert Comment

by:Jonyv
ID: 8216655
Which pins do you use to read the data from the microcontroller? If I remember correctly a standard parallell port only has 5 inputs (that can be read from the status port at 379H) The other 3 bits are outputs. This means that you can't read a whole byte at a time since you only have 5 bits so it's not surprising that you get strange values.

If you have a Bi-directional parallell port you can use the data lines to read input too, but in that case you should read from 378H.

Have a look at this article http://www.ee.washington.edu/circuit_archive/text/para-port.html
It has a lot of good information about interfacing the parallell port
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8217554
>> let's see who gets this one correct first
is this a puzzle , or some problem u stuck at ?
0
 
LVL 30

Author Comment

by:Mayank S
ID: 8217758
Well, frankly speaking, just a puzzle.. anybody can make that out, I guess.

Mayank.
0
 
LVL 5

Accepted Solution

by:
Kocil earned 120 total points
ID: 8217970
Some pins are inverted, the others are N/A.
Hmm ... let me see the book ...
Got it.
LP STATUS  Port 379H
-D7  BUSY 
D6   -ACK
D5   PE
D4  SELECT
D3  -ERROR
D2  -IRQ
D1  N/A
D0  N/A

If you feed it with 11111111b
You will get        01111100b
Equal               7Ch

Oops ???
Something wrong here. Are you sure you got 7Ah ???
0
 
LVL 30

Author Comment

by:Mayank S
ID: 8218023
Yeah! Buddy, I got 7Ah and 7CH, both lots of times. Anyways, its because pin no. 11 is read inverted, so the first-bit is read inverted, and as for the least-significant 3 bits, well, 379H is a 5-bit port so the last 3 bits can be high or low. They are generally all low, but may not be. That's why we generally AND the values read from 379H with F8H.

Anyways, thanks for giving it time everyone!

Mayank.
0
 
LVL 8

Expert Comment

by:akshayxx
ID: 8222094
>>Hmm ... let me see the book ...
i didnt have my books anywhere near me , any books i can see are in a language that i cant understand and am not willing to learn.. guess which one .. korean :(
0
 
LVL 30

Author Comment

by:Mayank S
ID: 8222902
>> i didnt have my books anywhere near me

.. never mind, Akshay buddy.. cheers :-)
0
 
LVL 5

Expert Comment

by:Kocil
ID: 8224089
Another puzzle please :)
0
 
LVL 30

Author Comment

by:Mayank S
ID: 8224121
Will have to wait... a little busy!
0
 
LVL 30

Author Comment

by:Mayank S
ID: 8224124
I know that for the last 2-3 days, there haven't been enough questions on EE, at least in C, C++, Java. That's why I ended up asking one!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
If you're a modern-day technology professional, you may be wondering if certifications are really necessary. They are. Here's why.
This video demonstrates how to use each tool, their shortcuts, where and when to use them, and how to use the keyboard to improve workflow.
The viewer will learn how to successfully download and install the SARDU utility on Windows 8, without downloading adware.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question