Can't get the parallel port working (Logic Analyzer project)

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all!

I am trying to build and understand Antonios Chorevas' "Low-Cost Logic Analyzer" (http://www.circuitcellar.com/AVR...)
I've attached the WinXP software ("terminal") which is meant to communicate with the AVR. I had to upgrade the code from VB to a .NET project, using Microsoft Visual Basic 2005. Executable found in bin/ directory.

The whole thing is now set up on my proto board, but I can't seem to get the "Comm with PC" part working (WinXP software attached). In the schematics (see Word document, in ZIP file at "Entry" link), the parallel port is described to connect as follows:

PIN#   PIN name    AVR
2      D0          PB0
3      D1          PB1
6      D4          PB5 (SCK)
7      D5          PB3 (MOSI)
9      D7          PC6 (RESET)
10     ACK         PB4 (MISO)
11     Busy        PB2

My parallel port is on an "extended IO bus"; a big clunk of hardware, which I can stick my laptop onto, giving me all sorts of ports.

I have a old printer cable, which I cut of the female connector. Using a multimeter, I found which wires map to which pins using the continuity test. As mentioned, it won't communicate with the PC; I've figured out that the AVR never gets past the "sync with pc"-part of the assembly code provided by Mr. Chorevas. I'm wondering if my parallel port could be differently mapped out, than the one he's got...

First, I have to disconnect the D7 connection (reset), because it simply keeps the AVR reset constantly. This is a first indication that something is "up" with my parallel port...

Next, the "sync with pc" part of the code waits for "CLK and START to go low" (see code fragment below). I can't figure out which specific pins these labels refer to, but, judging from the bitmasking

ANDI	temp,0b00000011

I expect this must be PB0 and PB1; namely, pins D0 and D1. And, by touching the corresponding pins on the AVR to ground, I do manage to pass through the initial sync process. By adding "debug code" (toggling LED's at particular points in the code), I verify that I actually get to the point in the code with the comment ";communicate with the PC".

The point is, I can't seem to get the PC to do this "handshaking" on it's own. And my question (finally) is; what can I do to get this working? It's not so much that I need this particular circuit, it's more that I really want to learn this stuff, and have been really struggling with this over the weekend.

For instance, I have a "parallel port monitor" software tool, which shows me which pins the PC software sets on the port. Also, it's supposed to let me set particular bits high and low. Still, the AVR does not respond when I toggle bits D0 and D1 low.
Do I need to remap the parallel port connections?

Btw, here's the info from my Device Manager:

    ECP Printer Port (LPT1) Device type: Ports (COM & LPT)
    Location: on Extended IO Bus
    I/O Range 0378-037F and 0778-077A
    Port settings: Never use an interrupt
    Device usage: Use this device (enable)

Hope someone feels like lending a hand :)

- Joakim

Code Fragment borrowed from http://www.circuitcellar.com/AVR...

sl5:

	;turn-on led
	CBI	PORTC,doneled

	;connect with the PC
	;initial state: START=high, CLK=high
	;wait till both START and CLK goes low / wait for 4 sec
	;/check states again / loop if changed/turn=off led if OK

con1:
	IN	temp,PINB
	ANDI	temp,0b00000011
	BRNE	con1

	wait4secs

	IN	temp,PINB
	ANDI	temp,0b00000011
	BRNE	con1

	SBI	PORTC,doneled

	;communicate with the PC
	;inactive phase: START=low, CLK=low
	;START goes high from the PC to begin transfer
	;data changes after rising edge of CLK signal
	;data is stable at the falling edge of the CLK signal

	;check for inactive state
	IN		temp,PINB
	BST		temp,pcstart
	BRTC	label1
	;fast blink led
	blinkled	30


label1:
	;initialize indexes
	LDI		Xhigh,01
	LDI		Xlow,00
	LDI		bitcounter,8
	LD		databyte,X+


	;wait till START goes high
label2:
	IN		temp,PINB
	BST		temp,pcstart
	BRTC	label2

loopt:
	;wait till CLK goes high
label3:
	IN		temp,PINB
	BST		temp,pcclk
	BRTC	label3

	;set next bit in output
	MOV		temp,databyte
	BST		temp,7
	BRTC	label4
	SBI		PORTB,pcdata
	RJMP	label5
label4:
	CBI		PORTB,pcdata
label5:

	;wait till CLK goes low
label6:
	IN		temp,PINB
	BST		temp,pcclk
	BRTS	label6

	;advance indexes
	LSL		databyte
	DEC		bitcounter
	BRNE	label7

	CPI		Xhigh,0x05
	BREQ	label8

	LDI		bitcounter,8
	LD		databyte,X+
label7:
	RJMP	loopt

label8:
	;slow blink led
	blinkled	60


; END OF PROGRAM

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you download the "inpout32.dll" ? This is needed to be able to control the port directly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

CirMicro wrote:
Did you download the "inpout32.dll" ? This is needed to be able to control the port directly.
Yes, it's in my C:\WINDOWS\system32 directory (along with something called parport.dll, which I believe came with some port-monitor tool I checked out). Thanks for replying :-D

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It sounds like the problem is on the PC side. I would write a simple test app to just twiddle the pins to known states that you can test with your meter to verify that you do have control. I didn't read the docs for this project, but sometimes the ParPort mode matters (ECP, Standard, etc.)

Good luck!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

try to see if it works on a standard PC (on board parallel interface). usually those extenders are build for printers

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right, so I dug up my old desktop pc, running Win98 and having a parallel port. But, for starters, I can't get the "terminal" software to run on this computer.

It seems win98 is having trouble dealing with the whole .NET thing. Is it possible to build the project (on my XP laptop) as a "windows 98 project"? I realize this is probably a bit off-topic, but still a part of the project I'm doing so I'm taking my chances... :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not a hope, things like .Net, Windows Media Player, Internet Explorer are deliberately engineered by Microsoft so they only work on the latest versions of Windows (in their current incarnations) on the basis of the fact that "otherwise everyone would still be using Win95 or an even earlier Windows". Sadly it looks like they'll eventually even phase out XP support and then we'll all be forced to migrate to Vista to use all the new "toys". As such there's no way you are going to get .Net working on Win98

Cliff
(still making do with IE6 on this Win2K machine as IE7 only works in XP and above)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My old Toshiba Satellite(which sadly drank a large glass of red wine, and never recovered) had some registry entry which I had to edit before I could use either the serial or the parallel port with my old DOS bit-banging stuff, even under 98. I think the port defaulted to disabled or power save mode. After that I had a Dell laptop with a printer port (Inspiron 512?). I specifically chose it beacause it had a built in parallel port (and serial, as it happens). I never managed to get any of my "legacy" programs, which bit-banged the printer port, to work. It was as though the port didn't exist under XP! (I know about UserPort/GiveIO stuff, BTW). In desperation I used to boot DOS from a USB memory stick. When it was stolen, I replaced it with a slightly newer Dell, but without a printer port(I don't believe they make 'em any more), thinking I might be able to buy a PCMCIA parallel card. Stupid me! Dell decided to switch to "Express Card" or something, and although I have since seen parallel devices on ebay, at the time I could not find one.

In desperation, I have now bought a Thinkpad T40 from ebay, which has a built-in parallel port, which actually WORKS under XP. The T41 also has an LPT, I don't know about later models...
Why do I need a printer port? Because Sharp, NXP(Philips), ST microelectronics and Conexant ALL use the LPT to talk I2C to certain evaluation kits.

Anyway, it might be worth trawling through the registry - although I can't tell you precisely what to look for.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Right... So I have this post in a VB forum, http://www.vbforums.com/showthre..., which seems to indicate that you can't avoid using the .NET framework (which doesn't seem to work/exist below XP)... :(

Is the parallel port really a lost cause?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well avrdude seems to have no problems make direct parallel port access in most Windows varaints (using the giveio.sys driver that is installed with it). giveio.sys in effect is similar to inoutp.dll in operation.