Link Search Menu Expand Document

AP482: Ten 32-Bit Counter / Timer Module

Software setup

Before using the AP482, you must install the AcroPack SDK on the BLOX. This chapter will guide you step by step to make sure everything is setup well.

Step 1 download the SDK

First of all, you need to download the latest version of the APSW-API-LNX from the AcroPack website. Therefore you need to create an account on the AcroMag website and go to this page. When the SDK is downloaded, unzip it on your local drive.

Step 2 copy the SDK to the BLOX

Go to the directory where you unpacked the SDK and copy the files to the BLOX with following command:

 $ sftp ai-blox@192.168.1.143
 ai-blox@192.168.1.143 password: ****
 connected to 192.168.1.143
 sftp> put -r 9500491D_SW

Where 192.168.1.143 is the IP address of the BLOX and 9500491D_SW is the unpacked directory. Both may be different in your case.

Step 3 login at the BLOX and check the AcroPack module

Next you need to login the blox and verify if the AcroPack module is recognized:

 $ ssh ai-blox@192.168.1.143
 ai-blox@192.168.1.143 password: **** 
 ai-blox@ubuntu:~$ lspci
 0004:00:00.0 PCI bridge: NVIDIA Corporation Device 1ad1 (rev a1)
 0005:00:00.0 PCI bridge: NVIDIA Corporation Device 1ad0 (rev a1)
 0005:01:00.0 Signal processing controller: Acromag, Inc. AP482 Counter Timer Module with TTL Level Input/Output

The last line tells us the the AP482 AcroPack module is corrected installed.

Step 4 build the kernel module

The AP482 need a kernel module to operate correctly. To build the module, you need to go to the ~/9500491D/AP48X/dev48x directory and execute make.

 ai-blox@ubuntu:~$ cd 9500491D_SW/AP48X/dev48x
 ai-blox@ubuntu:~/9500491D_SW/AP48X/dev48x$ make
 make -C /lib/modules/4.9.253-tegra/build  M=/home/ai-blox/9500491D_SW/AP48X/dev48x modules
 make[1]: Entering directory '/usr/src/linux-headers-4.9.253-tegra-ubuntu18.04_aarch64/kernel-4.9'
  CC [M]  /home/ai-blox/9500491D_SW/AP48X/dev48x/dev48x.o
  LD [M]  /home/ai-blox/9500491D_SW/AP48X/dev48x/ap482.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/ai-blox/9500491D_SW/AP48X/dev48x/ap482.mod.o
  LD [M]  /home/ai-blox/9500491D_SW/AP48X/dev48x/ap482.ko
  make[1]: Leaving directory '/usr/src/linux-headers-4.9.253-tegra-ubuntu18.04_aarch64/kernel-4.9'
 ai-blox@ubuntu:~/9500491D_SW/AP48X/dev48x$ ls
 ap482.ko  ap482.mod.c  ap482.mod.o  ap482.o  dev48x.c  dev48x.o  info.txt  Makefile  modules.order  Module.symvers

If everything went well, you will see the ap482.ko kernel module.

Step 5 install the kernel module

You need to copy the ap482.ko file to the /lib/modules directory and rebuild the module dependency list.

 ai-blox@ubuntu:~/9500491D_SW/AP48X/dev48x$ sudo cp ap482.ko /lib/modules/$(uname -r)/kernel/
 ai-blox@ubuntu:~/9500491D_SW/AP48X/dev48x$ sudo depmod

To auto load the module during boot, you need to add ap482 to the /etc/modules file

 ai-blox@ubuntu:~/9500491D_SW/AP48X/dev48x$ echo ap482 | sudo tee -a /etc/modules

To test if everything went well, reboot the device and check if the module is loaded

 ai-blox@ubuntu:~$ lsmod | grep ap482
 ap482                  11342  0

Step 6 add device nodes

Next we need to create the device node for the AcroPack module. To do this automatically after each boot, we need to add some code to the /etc/rc.local file. If the /etc/rc.local doesn’t exist, you need to create this file.

 ai-blox@ubuntu:~$ sudo vim /etc/rc.local

Make sure following code is add to the file

#!/bin/bash

#Acromag ap482
if [ ! -r /dev/ap482_0 ]; then
/bin/mknod -m 666 /dev/ap482_0 c 46 0 #(1st board)
/bin/mknod -m 666 /dev/ap482_1 c 46 1 #(2nd board)
/bin/mknod -m 666 /dev/ap482_2 c 46 2 #(3rd board)
/bin/mknod -m 666 /dev/ap482_3 c 46 3 #(4th board)
fi

Save the fill and in case you created the rc.local file, you need to set the permissions right.

 ai-blox@ubuntu:~$ sudo chmod +x /etc/rc.local

Reboot the device now and check if the device nodes are created after reboot.

 ai-blox@ubuntu:~$ ls /dev/ap*
 /dev/ap482_0  /dev/ap482_1  /dev/ap482_2  /dev/ap482_3

Step 7 test the device

Now all modules and device nodes are created, we can test the AcroPack module. The easiest way to do this is by using the example code in sdk.

 ai-blox@ubuntu:~$ cd 9500491D_SW/AP48X/
 ai-blox@ubuntu:~/9500491D_SW/AP48X$ make 
 cc -Wall -c ../apcommon/apcommon.c
 cc -Wall -c rmid48x.c
 cc -Wall -c rpntdio.c
 cc -Wall -c rprtdio.c
 cc -Wall -c wpntdio.c
 cc -Wall -c wprtdio.c
 cc -Wall -c cnfgct.c
 cc -Wall -c drvr48x.c
 cc -o a.out apcommon.o  rmid48x.o\
         rpntdio.o rprtdio.o wpntdio.o wprtdio.o cnfgct.o drvr48x.o
 ai-blox@ubuntu:~/9500491D_SW/AP48X$ chmod +x a.out
 ai-blox@ubuntu:~/9500491D_SW/AP48X$ ./a.out

This will start the demo program which allows you to configure the module. Please check the user manual of the module in case of any questions.

I/O connections

P2 Connector AcroPack Module P2 Connector
Description Pin# Pin# Pin# Pin# Description
Out3 1 69 1 35 In1 A
Out2 2 70 2 36 In0 A
Out5 3 73 5 37 In3 A
Out4 4 74 6 38 In2 A
Out7 5 77 9 39 In5 A
Out6 6 78 10 40 In4 A
Out9 7 81 13 41 In7 A
Out8 8 82 14 42 In6 A
Dout1 9 85 17 43 In9 A
Dout0 10 86 18 44 In8 A
DOut3 11 89 21 45 In1 B
Dout2 12 90 22 46 In0 B
Dout5 13 93 25 47 In3 B
Dout4 14 94 26 48 In2 B
GND 15 97 29 49 In5 B
Ext. Clock 16 98 30 50 In4 B
GROUND 17   33 51 In7 B
GROUND 18   34 52 In6 B
GROUND 19   37 53 In9 B
GROUND 20   38 54 In8 B
GROUND 21   41 55 In1 C
GROUND 22   42 56 In0 C
GROUND 23   45 57 In3 C
GROUND 24   46 58 In2 C
GROUND 25   49 59 In5 C
GROUND 26   50 60 In4 C
GROUND 27   53 61 In7 C
GROUND 28   54 62 In6 C
GROUND 29   57 63 In9 C
GROUND 30   58 64 In8 C
GROUND 31   61 65 Din1
GROUND 32   62 66 Din0
GROUND 33   65 67 Out1
GROUND 34   66 68 Out0