• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1714
  • Last Modified:

Port programming....

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
Mayank S
Asked:
Mayank S
  • 7
  • 2
  • 2
  • +2
1 Solution
 
cang24Commented:
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
 
Mayank SAssociate Director - Product EngineeringAuthor Commented:
378H is for sending data from the computer to the device.... I am reading from 379H.

Mayank.
0
 
Mayank SAssociate Director - Product EngineeringAuthor Commented:
(Standard for the parallel port, isn't it?)

Mayank.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
JonyvCommented:
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
 
akshayxxCommented:
>> let's see who gets this one correct first
is this a puzzle , or some problem u stuck at ?
0
 
Mayank SAssociate Director - Product EngineeringAuthor Commented:
Well, frankly speaking, just a puzzle.. anybody can make that out, I guess.

Mayank.
0
 
KocilCommented:
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
 
Mayank SAssociate Director - Product EngineeringAuthor Commented:
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
 
akshayxxCommented:
>>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
 
Mayank SAssociate Director - Product EngineeringAuthor Commented:
>> i didnt have my books anywhere near me

.. never mind, Akshay buddy.. cheers :-)
0
 
KocilCommented:
Another puzzle please :)
0
 
Mayank SAssociate Director - Product EngineeringAuthor Commented:
Will have to wait... a little busy!
0
 
Mayank SAssociate Director - Product EngineeringAuthor Commented:
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

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 7
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now