By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,315 Members | 1,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,315 IT Pros & Developers. It's quick & easy.

Writes to parallel port using assembler, sometimes crashes.

P: n/a
Hi,

Using the UserPort program that changes permissions in XP so that I am
able to write directly to the parallel port using assembler..

I'm trying to send out square wave pulses for x number of seconds. I'm
able to write and read from the parallel port, but after a few reads
and writes it crashes... how many reads and writes before it crashes
is not always the same.. sometimes it crashes at the first write or
read.. other times it can do 10 reads or writes...

Is windows halting my program in one of it's hickups and making my
program crash? I don't mind that the pulses are not always space
exactly the same in between.. so I don't need realtime processing..
Has anyone here tried this? Or do you know how to make sure the
program doens't crash?

Thanks,
Soren
Heres the code: It only demonstrate a few reads and writes.. if I put
it in a for/while loop, it'll certainly crash after a few iterations.
You need to start UserPort (http://www.embeddedtronics.com/public/
Electronics/minidaq/userport/UserPort.zip)
To enable direct write to the ports.

----------------------------------------------------

#include <iostream>
#include "windows.h"

using namespace std;

inline unsigned int
inb(unsigned short port)
{
unsigned char _v;
__asm__ __volatile__ ("inb %w1,%b0"
:"=a" (_v)
:"d" (port), "0" (0));

printf("Hello check\n");
return(_v);
}

inline void
outb(unsigned char value,
unsigned short port)
{
__asm__ __volatile__ ("outb %b0,%w1"
:/* no writes */
:"a" (value), "d" (port));
}

int main()
{
int i;
int c;
int port = 0x378;

cout << "Press enter to begin: ";
cin >i;

//outb(0, port+0); // write to parallel port

Sleep(100);

c = inb(port+0);

Sleep(100);
printf("Val = : %d", c);

outb(255, port+0);
Sleep(100);

c = inb(port+0);
printf("Val = : %d", c);

return 0;
}
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ss******@gmail.com wrote:
Hi,

Using the UserPort program that changes permissions in XP so that I am
able to write directly to the parallel port using assembler..

I'm trying to send out square wave pulses for x number of seconds. I'm
able to write and read from the parallel port, but after a few reads
and writes it crashes... how many reads and writes before it crashes
is not always the same.. sometimes it crashes at the first write or
read.. other times it can do 10 reads or writes...

Is windows halting my program in one of it's hickups and making my
program crash? I don't mind that the pulses are not always space
exactly the same in between.. so I don't need realtime processing..

[redacted]
Wrong group. Try one with "microsoft" or "windows" in its name.

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.