- From: Ian Abbott <abbotti_at_mev.co.uk>
- Date: Tue, 22 Nov 2005 19:15:30 +0000
On 22/11/05 13:50, Per Arlock wrote:
> I have been trying to use the counters on the two boards (advantage
> pci1710 and 1711). As I understand in the doc's both should have
> counter functions in the drivers. Or have I misunderstood? Anyhow,
> when running ./info I find that 1710 have a counter subdev whereas
> 1711 have not. Since I have both types of the cards it does not
> matter much.
I'm not familiar with either board, so I cannot say why the 1711 does
not have a counter subdevice.
> I have tied cnt0_gate to +5, cnt0_out to ground and connected a ttl
> generator to cnt0_clk. Running ./inp -s 4 gives repeatedly the same
> value. After ./outp -s 4 -c 0 0 I again run ./inp -s 4. The counter
> seems to run but the values are any number between 0 65500 and do not
> follow the generator.
> Where am I completely wrong?
> I would be very grateful for some information on this problem!
It seems that the driver initializes the counter to count from the
internal 100 kHz clock source. There is some old code that used to
allow the counter to be configured to count from the external clock, but
that code is ifdef'd out.
Counting the internal clock source doesn't seem very useful except for
test purposes. I guess it would be more useful to count the external
input. :-)
Try the one-liner patch at the end of this email. It configures the
board to use the external input for counter 0. I've no idea what
side-effects this has on the rest of the board's functions,so you'll
have to test it thoroughly.
Once you've written to the counter, you should find it has some random
value until the first clock pulse (which loads the counter with the
value written), then it should count down by 1 every clock pulse until
it reaches 0, then it will wrap around to 65535. I.e. the sequence is
of writes, reads and clocks may be something like this:
write N
read XXXX
clock
read N
clock
read N-1
...
clock
read 0
clock
read 65535
clock
read 65534
Regards,
Ian Abbott.
Patch follows:
Index: comedi/drivers/adv_pci1710.c
===================================================================
RCS file: /var/cvs/comedi/comedi/drivers/adv_pci1710.c,v
retrieving revision 1.28
diff -u -r1.28 adv_pci1710.c
--- comedi/drivers/adv_pci1710.c 6 Oct 2005 17:42:02 -0000 1.28
+++ comedi/drivers/adv_pci1710.c 22 Nov 2005 18:46:59 -0000
_at__at_ -1157,7 +1157,7 _at__at_
{
DPRINTK("adv_pci1710 EDBG: BGN: pci171x_reset(...)\n");
outw(0x30, dev->iobase + PCI171x_CNTCTRL);
- devpriv->CntrlReg=Control_SW; // Software trigger, CNT0=100kHz
+ devpriv->CntrlReg=Control_SW|Control_CNT0; // Software trigger, CNT0=external
outw(devpriv->CntrlReg, dev->iobase+PCI171x_CONTROL); // reset any operations
outb(0, dev->iobase + PCI171x_CLRFIFO); // clear FIFO
outb(0, dev->iobase + PCI171x_CLRINT); // clear INT request
Received on 2005-11-22Z19:15:30