LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Writing to parallel port 0x37a works, 0x378 don't (https://www.linuxquestions.org/questions/linux-hardware-18/writing-to-parallel-port-0x37a-works-0x378-dont-458808/)

Pier 06-27-2006 11:49 AM

Writing to parallel port 0x37a works, 0x378 don't
 
Hi everybody,
I am going mad with this: I am writing a test program to spin a stepper connected to the parallel port. Being D0=step_pin, D1=dir_pin, C2=enable_pin.
The few c code lines I wrote:
1) get the ioperm(0x378,3,1) that returns no error;
2) enable the stepper with outb(C2,0x37a)
before entering the "for" cycle that sends outb(step+dir,0x378) N (on off) sequences,
the stepper starts humming and spinning always the same way with the same pace (regardless the D1 direction value and the delay value)
It looks like (I verified it with a multimeter) there is always some process sending the 0x378 pins a squared wave of around 100Hz preventing any actions on 0x378.
Control 0x37a works fine and the stepper is easily switched on and of (ie energized).

From Bios I switched to SPP mode and suid(0) in the code but with no success.

Could anyone helpme to get this sorted out?

I even modprobe -r (lp, parport and parport_pc)

Thanks a lot,
Pier

PS
The stepper works fine with a C (dos) program.

Slack 10.2 Ker. 2.4.31

Matir 06-27-2006 01:43 PM

Are you checking return values from your calls to check for errors? I would guess you need to send
Code:

outb(D0,0x378);
outb(D0+D1,0x378);

back and forth.

Pier 06-27-2006 02:04 PM

Quote:

Originally Posted by Matir
Are you checking return values from your calls to check for errors? I would guess you need to send
Code:

outb(D0,0x378);
outb(D0+D1,0x378);

back and forth.

I just check ioperm return code and, as far as I know, it is OK. I'll try and alter the code as you has suggested above even though I am a bit skeptical. I'll turn up soon with the results.

Thanks,
Pier

Pier 06-27-2006 04:51 PM

Hi,
the plot thickens!
I wired the stepper to other pins: first to D2(step) D3(dir) C0(enable) and then D4(step) D5(dir) C1(enable) to see if things changed. As a matter of fact this time the stepper rotated consistently with the command given (apart from insensitivenes to usleep interval ....)
There must be something wrong with Pin2 and Pin3 (ie D0 and D1).
Removing modules lp, parport and parport_pc, the stepper does not work at all. Insmoding just parport_pc though, the test program works but not when sending steps through pins 2 and 3. Could perhaps be something related to parport_pc that sends signals through D0 and D1?

Thanks for any help,
Pier


All times are GMT -5. The time now is 02:29 AM.