Now i added the  timeout errors checking (code below), but still the same. 

I noticed that the address_strobe line is low when i start the pc, and stays 
low even when i execute my code. But then after I run the hal-hostmot, the 
address_strobe goes to 1. So it seems that in my code the epp was not set 
correctly, i dont know why, i have the outb(0x80,extctrl_addr).



#define STATUS_SELECT   4
#define STATUS_PAPEREND 5
#define STATUS_nACK     6
#define STATUS_nBUSY    7

#define TEST_BIT( x, b )   (((x) & (1<<(b))) != 0 )
#define SET_BIT( x, b )    ((x) |= (1 << (b)))
#define CLEAR_BIT( x, b )    ((x) &= ~(1 << (b)))


typedef struct _Status
{
    unsigned char timeout, error, select, paper_end, ack, busy;
} Status;


/* Checks and returns each bit of the status register */
void read_status(int port_addr, Status *stat)
{
  unsigned char status;

  status = inb(port_addr + STATUS_PORT); // read the status port

  stat->timeout     = TEST_BIT( status, STATUS_TIMEOUT );
  stat->error       = 1 - TEST_BIT( status, STATUS_nERROR );
  stat->select      = TEST_BIT( status, STATUS_SELECT );
  stat->paper_end    = TEST_BIT( status, STATUS_PAPEREND );
  stat->ack         = 1 - TEST_BIT( status, STATUS_nACK );
  stat->busy        = 1 - TEST_BIT( status, STATUS_nBUSY );

 
 
  if ( stat->timeout )  // We clear the timeout bit by writing 1 to bit 0 
(might need to change)
  {
    status = status | STATUS_TIMEOUT; // clears by writing 1
    outb(port_addr+STATUS_PORT, status);
  }
}


/* returns 1 when there was some problem with the last operation */
int check_status(int port_addr)
{
  Status stat;
  read_status(port_addr, &stat); // read status and clear timeout bit
  return (stat.timeout || stat.error || ! stat.select || stat.busy);
}



int main(int argc, char *argv[])
{
    int base_addr, extctrl_addr;
    unsigned char status, control;

    if (argc==1) { printf("must enter parallel port I/O address\n"); }
    if (argc > 1) {
        if (1==sscanf(argv[1],"%x",&base_addr)) {
        iopl(3) ;//turn on access to all I/O
        extctrl_addr = base_addr + 0x402;
        outb(0x80,extctrl_addr);  // set for EPP mode
        printf("wrote 0x80 to 0x%x\n",extctrl_addr);
        outb(base_addr + CONTROL_PORT, 0x04 ); // reset
    

        check_status(base_addr);

        outb(0x11, base_addr+4);
        check_status(base_addr);
        outb(0x11, base_addr+4);
        check_status(base_addr);
        outb(0x11, base_addr+4);
        check_status(base_addr);
        outb(0x11, base_addr+4);
        check_status(base_addr);

        outb(0x11, base_addr+3);
        check_status(base_addr);
        outb(0x11, base_addr+3);
        check_status(base_addr);
        outb(0x11, base_addr+3);
        check_status(base_addr);
        outb(0x11, base_addr+3);
        check_status(base_addr);        
        
        status = inb(base_addr + STATUS_PORT);
        printf("status byte: 0x%x\n",status); // always returns 0xff ???
    
        

        

    }
  }
  return 0;
}



________________________________
 From: Peter C. Wallace <[email protected]>
To: Klemen Dovrtel <[email protected]>; Enhanced Machine Controller 
(EMC) <[email protected]> 
Cc: andy pugh <[email protected]> 
Sent: Friday, February 8, 2013 9:23 PM
Subject: Re: [Emc-users] EPP data transfers
 
On Fri, 8 Feb 2013, Klemen Dovrtel wrote:

> Date: Fri, 8 Feb 2013 11:51:09 -0800 (PST)
> From: Klemen Dovrtel <[email protected]>
> To: andy pugh <[email protected]>,
>     "Enhanced Machine Controller (EMC)" <[email protected]>
> Subject: Re: [Emc-users] EPP data transfers
> 
> Now I tested the hostmod2 halsetup you suggested and i noticed the 
> address_strobe signal was alive. After that i tested my code again and now 
> everything worked fine - i can see the address_strobe signal with the 
> oscilloscope.
>
>
> So there is a line in your hostmod2 setup code that solves my epp parallel 
> port problem. Any idea what could that be?

Probably either setting the port into EPP mode is not being done or perhaps 
your code is not checking and clearing any possible timeout errors before 
you start.
>
>
> I tried this (see below), but no luck:
>
> int main(int argc, char *argv[])
> {
>     int base_addr, extctrl_addr;
>     unsigned char status, control;
>
>     if (argc==1) { printf("must enter parallel port I/O address\n"); }
>     if (argc > 1) {
>         if (1==sscanf(argv[1],"%x",&base_addr)) {
>         iopl(3) ;//turn on access to all I/O
>         extctrl_addr = base_addr + 0x402;
>         outb(0x80,extctrl_addr);  // set for EPP mode
>         printf("wrote 0x80 to 0x%x\n",extctrl_addr);
>
>         outb(0x11, base_addr+4);
>         outb(0x11, base_addr+4);
>         outb(0x11, base_addr+4);
>         outb(0x11, base_addr+4);
>
>
>         outb(0x11, base_addr+3);
>         outb(0x11, base_addr+3);
>         outb(0x11, base_addr+3);
>         outb(0x11, base_addr+3);
>        
>        
>         status = inb(base_addr + STATUS_PORT);
>         printf("status byte: 0x%x\n",status); // always returns 0xff ???
>    
>         outb(base_addr + CONTROL_PORT, 0x04 ); // reset the peripheral,
>
>         status = inb(base_addr + STATUS_PORT);
>         printf("status byte: 0x%x\n",status); // always returns 0xff ???
>
>
>         // reset
>         control = inb(base_addr + CONTROL_PORT);
>         printf("control byte: 0x%x\n",control);
>           CLEAR_BIT( control, CONTROL_nINIT );
>         printf("control byte clear: 0x%x\n",control);
>           outb( base_addr + CONTROL_PORT, control );
>           SET_BIT( control, CONTROL_nINIT );
>         printf("control byte set: 0x%x\n",control);
>           outb( base_addr + CONTROL_PORT, control );
>
>
>         outb(0x11, base_addr+4);
>         outb(0x11, base_addr+4);
>         outb(0x11, base_addr+4);
>         outb(0x11, base_addr+4);
>
>
>         outb(0x11, base_addr+3);
>         outb(0x11, base_addr+3);
>         outb(0x11, base_addr+3);
>         outb(0x11, base_addr+3);
>
>     }
>   }
>   return 0;
> }
>
>
>
>
>
>
>
>
>
>
> ________________________________
> From: andy pugh <[email protected]>
> To: Klemen Dovrtel <[email protected]>; Enhanced Machine Controller 
> (EMC) <[email protected]>
> Sent: Thursday, February 7, 2013 3:27 PM
> Subject: Re: [Emc-users] EPP data transfers
>
> On 6 February 2013 20:00, Klemen Dovrtel <[email protected]> wrote:
>
>> Any idea what could be wrong? Does anybody have a simple code (executable) 
>> that send the data using address_write/address_read so that i can test my 
>> hardware?
>
> Running either the Pico PPMC or Mesa 7i43 drivers from the command
> line ought to toggle the pins, though not necessarily in the way you
> need.
>
> halrun
> loadrt hostmot2   
> loadrt hm2_7i43 ioaddr=0x378 ioaddr_hi=????  debug_epp=Y
> exit
>
> -- 
> atp
> If you can't fix it, you don't own it.
> http://www.ifixit.com/Manifesto
> ------------------------------------------------------------------------------
> Free Next-Gen Firewall Hardware Offer
> Buy your Sophos next-gen firewall before the end March 2013
> and get the hardware for free! Learn more.
> http://p.sf.net/sfu/sophos-d2d-feb
> _______________________________________________
> Emc-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/emc-users
>

Peter Wallace
Mesa Electronics

(\__/)
(='.'=) This is Bunny. Copy and paste bunny into your
(")_(") signature to help him gain world domination.
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to