developing drivers for custom boards

More
26 Mar 2013 23:50 #31933 by andypugh

Now, in my clueless way, I seem to have almost filled my 4G HDD. I can only assume this is from my blantent use of RTAPI_PRINT running in a thread.


Ah, yes, you have to be careful of that.

sudo dmesg -c might help.
Otherwise, have a look in /var/log/

Please Log in or Create an account to join the conversation.

More
27 Mar 2013 03:34 #31939 by btvpimill
Having some trouble with what seems like too many bytes being sent. Before I added pin SP everything worked wonderful. 4 bytes were sent (I used to have 32 pins). Now That I have added SP-out, it seems like byte 1, byte 2, and byte are being sent twice. but in order. I am hoping this is a quick dum dum on my part that you guys can help me sort quickly. Here is my current listing:
component fc1;

pin in bit pin-##-out[24] "output pins";<<<<<<<<<<<<<<<<<<<<<<used to be 32, not 24
pin out bit pin-##-in[24] "input pins";
pin in unsigned SP-out "speed/temp value";
pin out unsigned R0-in;
pin out unsigned R1-in;
pin out unsigned R2-in;
pin out unsigned R3-in;
pin out unsigned R0-out;
pin out unsigned R1-out;
pin out unsigned R2-out;
pin out unsigned R3-out;

function read nofp;
function write nofp;

variable unsigned base_addr;

option count_function yes;
option extra_setup yes;

modparam dummy ioaddr """Base address of card. Separate each card base address
with a comma but no space to load more than one card. eg
loadrt fc1 ioaddr=0x378,0xdf00. use 0xNNN to define addresses in Hex""";

modparam dummy con """Configuration values for card. Seperate each value with
a comma and no spaces. 12 values are expected, see readme for value explanation"""

license "GPL";
author "Andy Pugh modified by Bert Lewis";
;;

#include <asm/io.h>
#define MAX_CHAN 8

static int con[12] = {0,0,0,4,5,6,7,8,9,10,11,12};
RTAPI_MP_ARRAY_INT(con,12,"configs")

static int ioaddr[MAX_CHAN] = {0x378, -1, -1, -1, -1, -1, -1, -1};
RTAPI_MP_ARRAY_INT(ioaddr, MAX_CHAN, "Base addresses")

FUNCTION(read){
unsigned char R0, R1, R2;
int i;
R0 = inb(base_addr + 3);
R1 = inb(base_addr + 4);
R2 = inb(base_addr + 4);

R0_in = R0;
R1_in = R1;
R2_in = R2;

for (i = 0;i <= 7;i++){
pin_in(i) = R0 & (1 << i);
pin_in(i+8) = R1 & (1 << i);
pin_in(i+16) = R2 & (1 << i);
}
}

FUNCTION(write){
unsigned char R0, R1, R2, SPi;
int i;
R0 = 0;
R1 = 0;
R2 = 0;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Used to have R3=0 after this line
for (i = 0;i <= 7;i++){
R0 |= pin_out(i) << i;
R1 |= pin_out(i+8) << i;
R2 |= pin_out(i+16) << i;<<<<<<<<<<<<<<<<<<<<<<There was a line after this to get R3 |=pin_out(i+24)<<i;
}
SPi = SP_out;

outb(R0, base_addr + 3);
outb(R1, base_addr + 4);
outb(R2, base_addr + 4);
outb(SPi, base_addr + 4);<<<<<<<<<<<<<<<<<<<<<<<This used to be R3, not SPi

R0_out = R0;
R1_out = R1;
R2_out = R2;

}

EXTRA_SETUP(){
int c;
if (ioaddr[extra_arg] > 0) {
base_addr = ioaddr[extra_arg];
rtapi_print("Loading EPP custom board driver at base addr %X\n", base_addr);
c=inb(base_addr+0x402);
c=c&0x1f;
c=c|0x80;
outb(c,base_addr+0x402);
outb(4,base_addr+2);

outb (0,base_addr+3);
for (c=0;c<12;c++){
outb(con[c],base_addr+4);
}
rtapi_print("made it past EPP setup\n");
return 0;
}
rtapi_print("Seems we are returning -EINVAL %X\n",EINVAL);
return -EINVAL;
}

int get_count(void){
int i;
for (i=0; ioaddr[i] > 0 && i < MAX_CHAN; i++){}
rtapi_print("down here in get count, i = %X\n", i);
return i;
}

Please Log in or Create an account to join the conversation.

More
27 Mar 2013 06:30 - 27 Mar 2013 06:31 #31947 by andypugh
Sorry, no, I am not spotting anything wrong there.

(You probably should change the author name now, though)
Last edit: 27 Mar 2013 06:31 by andypugh.

Please Log in or Create an account to join the conversation.

More
27 Mar 2013 06:34 #31948 by btvpimill
well at least I can have confidence it is not the driver then.
As for the author name, I can do that :) - that much I know how to do at least

Please Log in or Create an account to join the conversation.

More
28 Mar 2013 05:05 #31987 by btvpimill
Verified it is not the driver using a 8 bit Logic probe to capture the port traffic. Seems I have some issues not ironed out yet in my card. Next step is to use a "manual" parallel port to talk to my card, that way I can single step and see what is going wrong.

Thanks for you help, I would never have gotten this far without it.

BTW, took you off as the author :)

Please Log in or Create an account to join the conversation.

More
29 Mar 2013 04:12 #32009 by btvpimill
parallel EPP comms are running perfectly now. New questions -
is there a way to change the thread period in halrun?
is there a way to run a thread (or the functions in the thread) just once?
Is there somewhere I have not found listing the halrun commands so I do not need to bother you guys with these things? Seems like I have read all the HAL docs online, but surely I have missed this.

Please Log in or Create an account to join the conversation.

More
29 Mar 2013 04:16 #32010 by dgarrett
$ halrun
halcmd: help
Use 'help <command>' for more details about each command
Available commands:
loadrt Load realtime module(s)
loadusr Start user space program
waitusr Waits for userspace component to exit
unload Unload realtime module or terminate userspace component
lock, unlock Lock/unlock HAL behaviour
linkps Link pin to signal
linksp Link signal to pin
net Link a number of pins to a signal
unlinkp Unlink pin
newsig, delsig Create/delete a signal
getp, gets Get the value of a pin, parameter or signal
ptype, stype Get the type of a pin, parameter or signal
setp, sets Set the value of a pin, parameter or signal
addf, delf Add/remove function to/from a thread
show Display info about HAL objects
list Display names of HAL objects
source Execute commands from another .hal file
status Display status information
save Print config as commands
start, stop Start/stop realtime threads
alias, unalias Add or remove pin or parameter name aliases
quit, exit Exit from halcmd
halcmd: help loadrt
loadrt modname [modarg(s)]
Loads realtime HAL module 'modname', passing 'modargs'
to the module.
halcmd:

Please Log in or Create an account to join the conversation.

More
29 Mar 2013 05:09 #32011 by andypugh

is there a way to change the thread period in halrun?.

It is an optional argument in your "loadrt threads" line:
www.linuxcnc.org/docs/html/man/man9/threads.9.html
Unless you are using motmod, in which case it is an optional parameter to loadrt motmod.
www.linuxcnc.org/docs/html/man/man9/motion.9.html

Please Log in or Create an account to join the conversation.

More
27 Apr 2013 21:33 #33286 by btvpimill
Thanks to everyones help here, I finally just about have a fully functional driver and card. I am left with 1 tiny but huge issue -

when the computer boots, address strobe goes low, causing my card to think an address is about to be sent, the problem seems to be that the computer is not yet in EPP mode so my card never sees address strobe go back high.

I need some logic to know when it is in EPP mode. I tried to send a byte out after setting EPP mode in the driver, but it seems like my card misses it so that didn't work.

Looking for any suggestions on this.

Please Log in or Create an account to join the conversation.

More
27 Apr 2013 22:05 #33287 by andypugh

I need some logic to know when it is in EPP mode. .


One common solution to this type of problem is a charge-pump / watchdog circuit.
ie, there is hardware that keeps everything disabled unless there is a regular strobe on one pin.

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.177 seconds
Powered by Kunena Forum