TS-CAN1
Documents | |
---|---|
Schematic | |
LinCAN Manual | |
Ocera CANOpen Manual | |
SJA1000 Datasheet |
Overview
TS-CAN1 is a PC/104 daughter board which provides one single CAN interface channel and enables a PC/104 embedded systems to be connected to CAN1.1 and CAN2.0a networks. It uses a Philips SJA1000 CAN controller which is opto-isolated from the physical CAN network, increasing the system security. On-board jumpers are used to select both the interrupt and the I/O region used. Also, the on-board termination resistor is jumper selectable. Up to four boards can be installed in any single system. The SJA1000 controller can be configured to communicate with the processor through 8 different 32-bytes I/O regions.
Note: | The TS-CAN1 is compatible with both X86 and ARM architectures. |
Hardware Configuration
Jumper settings for I/O Address Selection
IO Address | JP1 | JP2 |
---|---|---|
150-157 | Off | Off |
158-15F | On | Off |
160-167 | Off | On |
168-16F | On | On |
Jumper settings for IRQ Selection
IRQ | JP4 | JP5 |
---|---|---|
None | Off | Off |
IRQ5 | On | On |
IRQ6 | On | Off |
IRQ7 | Off | On |
CAN 10 Pin Header
Pin Number | Signal |
---|---|
1 | X |
2 | CANL |
3 | GND |
4 | X |
5 | X |
6 | GND |
7 | CANH |
8 | X |
9 | X |
10 | X |
The physical pin numbering is as follows. The top row is the side closest to the edge of the board. The dot in the table represents the pin with the square pad.
6 | 7 | 8 | 9 | 10 |
---|---|---|---|---|
.1 | 2 | 3 | 4 | 5 |
Note: | TS-7200, TS-7250, TS-7260, and TS-7300 I/O space starts at 0x11E0_0000 physical address. For example, 0x150 I/O space is decoded at 0x11E0_0150 physical memory.
|
PLD Register Map
IO Address | Description | Access | Details | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Base + 0 | Board Identifier #1 | R | Fixed hex value: 0xF6 | ||||||||||||||||
Base + 1 | Board Identifier #2 | R | Fixed hex value: 0xB9 | ||||||||||||||||
Base + 2 | PLD Version Register | R | Fixed value | ||||||||||||||||
Base + 3 | LED control/status | RW |
| ||||||||||||||||
Base + 4 | Page selection register | RW |
| ||||||||||||||||
Base + 5 | Mode control Register | RW |
| ||||||||||||||||
Base + 6 | Jumper Status | R |
| ||||||||||||||||
Base + 7 | Reserved |
SJA1000 IO Page Selection Reg
Page | Registers | Bit1 | Bit0 |
---|---|---|---|
1 | 00-1f | 0 | 0 |
2 | 20-3f | 0 | 1 |
3 | 40-5f | 1 | 0 |
4 | 60-7f | 1 | 1 |
SJA1000 IO Address Selection Register
WARNING This register MUST be different from the PLD register chosen using the jumper configuration, and ALSO must be different from all other devices in the PC104 stack or an address conflict WILL occur. The default address is 0x100.
Address Range | Bit2 | Bit1 | Bit0 |
---|---|---|---|
100-11f | 0 | 0 | 0 |
120-13f | 0 | 0 | 1 |
180-19f | 0 | 1 | 0 |
1A0-1Bf | 0 | 1 | 1 |
200-21f | 1 | 0 | 0 |
240-25f | 1 | 0 | 1 |
280-29f | 1 | 1 | 0 |
320-33f | 1 | 1 | 1 |
Software Support
SJA1000 Programming
The TS-CAN1 was designed using the SJA1000 CAN controller. The SJA1000 provides support for CAN2.0 networks and supports BasicCAN and PeliCAN modes. For further information about SJA1000 and how to interact with it through its registers, please check the specific Datasheet and Application Notes:
- https://www.nxp.com/products/interfaces/can-transceivers/legacy-can/stand-alone-can-controller:SJA1000T
- https://www.nxp.com/docs/en/data-sheet/SJA1000.pdf
- https://www.nxp.com/docs/en/application-note/AN97076.pdf
LinCAN Driver for Linux
Note: | This section and its accompanying subsections apply to embeddedTS products that use Linux 2.6.x and below. See the following section on SocketCAN for compatibility with newer products |
The Linux device driver for TS-CAN1 was developed using the OCERA framework for CAN, which is composed of LINCAN, VCA, CAN/CANOpen Monitor and CANOpen Device. LINCAN is a generic Linux device driver implementation that supports many boards. It is an evolution of other CAN open-source projects for Linux. The Virtual CAN API (VCA) is an interface that hides LINCAN driver specifics from user space programmer, increasing the development speed and compatibility. CAN/CANOpen Monitor is a tool (application server and Java GUI client) that enables monitoring and interaction with a CAN network using client/server applications. CANOpen Device is a library based on VCA that provides a high-level protocol for device integration over LINCAN using CANOpen master and slave components. For further information on OCERA/LINCAN framework, please see the links:
Note: | This guide was written to cover both TS-CAN1 and TS-7KV hardware and the Lincan driver is compatible with both. |
New: The original lincan author has notified Technologic Systems that a newer version of lincan is available here: http://ortcan.sourceforge.net/lincan/
This new source has not yet been tested by Technologic Systems.
Installing the Ocera/Lincan Files
The files are available at the TS ftp server (https://files.embeddedTS.com/old/can):
- oceralincan_arm.tar.gz : tarball with ocera/lincan files for TS ARM boards
- lincan_arm.tar.gz : tarball with last version of the lincan driver for TS ARM boards
- oceralincan_x86.tar.gz : tarball with ocera/lincan files for TS X86 boards
- lincan_x86.tar.gz : tarball with last version of the lincan driver for TS X86 boards
More recent versions of the Lincan driver can be found at:
If you need the source code of OCERA/LINCAN, please follow the link below to get access to OCERA at CVS or download the source tree used by Technologic Systems:
- https://sourceforge.net/projects/ortcan/files/lincan/
- https://files.embeddedTS.com/pc104-peripherals/ts-can1/ts-72xx-linuxr24/oceralincan_arm.tar.gz
Extracting the two tarballs for your specific architecture (ARM or X86) at the root directory of your target system will create the /usr/lincan/ directory filled with all needed files (All the examples in this guide assume that root is your working directory). Use the following commands replacing xxx with the appropriate architecture name:
# tar zxvf oceralincan_xxx.tar.gz -C / # tar zxvf lincan_xxx.tar.gz -C /
Loading the LinCAN Driver
The Lincan driver for TS-CAN1 implements a plug and play feature. So, the driver is able to detect the hardware, I/O address and IRQ line being used. To take advantage of the implemented plug and play feature, load the driver into the kernel by executing the command below:
# cd /usr/lincan/modules/ # insmod -f lincan.o hw=tscan1 (in case your board is a TS-CAN1) # insmod -f lincan.o hw=ts7kv (in case your board is a TS-7KV) # insmod -f lincan.o hw=ts732 (in case your board is a TS-732)
SocketCAN Driver for TS-7800-V2
The Linux Kernel provides upstream compatibility for ISA-based SJA1000 CAN controllers. This driver can make up to three TS-CAN1 peripherals show up as network devices in Linux thus:
root@ts-7800-v2:~# ifconfig can1 can1: flags=128<NOARP> mtu 16 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 123 base 0x100 root@ts-7800-v2:~#
The driver module is provided already installed in all embeddedTS software packages that supports SocketCAN with the TS-CAN1. Set the PLD registers for operation and load the driver with the appropriate comma-separated IO and IRQ configurations (commas only necessary for multiple TS-CAN1). Example, for one TS-CAN1 used on the TS-7800-V2:
root@ts-7800-v2:~# source /sbin/ts7800.subr #load the TS-7800-V2 BASH Macro set root@ts-7800-v2:~# pc104on #enable PC104 with the appropriate macro root@ts-7800-v2:~# peekpoke 8 0xfa000150 #Check the peripheral ID for presence of the TS-CAN1 0xF6 root@ts-7800-v2:~# peekpoke 8 0xfa000155 0x40 #Enable SJA1000 functions on PC104 IO offset 0x100 0x40 root@ts-7800-v2:~# modprobe sja1000_isa mem=0xfa000100 irq=123 clk=25000000 [ 92.146672] sja1000_isa sja1000_isa.0: sja1000_isa device registered (reg_base=0xf1634100, irq=123) [ 92.159233] Legacy sja1000_isa driver for max. 8 devices registered
Two TS-CAN1 would be very similar to the above example, instead set up each TS-CAN1 with addreses separately, then call the driver just once with the list of TS-CAN1 to be instantiated:
root@ts-7800-v2:~# modprobe sja1000_isa mem=0xfa000100,0xfa000200 irq=6,6
Testing the CAN Network
You can use the testing tools available at /usr/lincan/bin-utils directory. For example, to set up your CAN hardware to listen to messages from a working CAN network, use the following command:
# ./readcan /dev/can0
To send messages out to a CAN network, you can use the sendburst tool. For example, to send out #3 can messages with identifiers #1 on each #1 second of period, do:
# ./sendburst --help # ./sendburst -d/dev/can0 -w1 -b3 -i1
To find further information about either the binary tools or LIBVCA and CAN/CANOpen, please view the OCERA documentation:
- http://www.ocera.org/archive/deliverables/ms4-month24/WP7/D7.4.pdf
- http://cmp.felk.cvut.cz/~pisa/can/doc/ocera-canopen-ug.pdf
More Control Over the Driver
If you need more control over the driver configuration, you can skip the plug and play feature and use the module parameters. Get more information about the Lincan driver using the modinfo tool. For TS-CAN1, the relevant driver parameters are:
- hw: Name of the TS hardware being used. It should be tscan1 if using TS-CAN1 card, ts7kv if using TS-7KV card or ts732 if using a TS-732 card.
- io: The I/O address used by the card. It must be in accordance with the jumper selection. Use io=0x150 if jumper selection is all OFF for ARM I/O, for example.
- irq: The IRQ address used by the card. It must be in accordance with the jumper selection. For ARM platform, use irq=33 when jumper selection is IRQ 6, irq=40 when jumper selection is IRQ 7, and irq=21 when jumper selection is IRQ 5
- canio: Use this parameter for setting a specific I/O address space to allocate the SJA1000 registers. It is only available with TS-CAN1. See the table SJA1000 I/O address selection register in previous section.
- clock: Clock frequency of the on-board crystal/oscillator in step of 1kHz. The default is clock=16000 for 16Mhz on TS-CAN1 and clock=24000 for 24Mhz on TS-7KV.
- baudrate: Bit rate for the SJA1000 communication with the CAN network in step of 1kHz. The default is baudrate=1000 for 1Mbps.
Note: | If your CAN card is a TS-732, the Lincan driver will only support the hw and baudrate parameters. The clock is default set to 25Mhz and the IRQ is 40. The default baudrate is set to 500Kbps. |
Using Additional TS-CAN1 Cards in a Single System
Note: | This section applies only to the use of the LinCAN driver |
By using more than one TS-CAN1 card on a single system, you can set up a CAN network for testing and development with a single target embedded hardware. The Lincan device driver supports up to 8 CAN boards. You can load a single driver to give support to all cards by setting the appropriate parameters on driver loading. The parameters of the driver can be extended by using index commas. For example, to set up the Lincan driver to support 3 different CAN boards and use plug and play functionality:
# insmod -f lincan.o hw=tscan1,ts732,ts7kv
If you want to set specific values to the other parameters, it is possible to skip the plug and play functionality by assigning values others than -1. Notice that the -1 value tells the driver to use plug and play or default values to the specific parameter.
The next example loads the LINCAN driver to support two TS-CAN1 boards and one TS-7KV. The I/O space of the first board is 0x150, while the others are plug and play configured. The same methodology can be applied for IRQ and baudrate configuration.
# insmod -f lincan.o hw=tscan1,tscan1,ts7kv io=0x150,-1,-1 irq=-1,-1,33 baudrate=1000,500,-1
Note: | TS-ARM based systems can be set up with a maximum of 4 TS-CAN1 boards and 4 TS-7KV boards. Thus, you are able to have up to 8 CAN interfaces running simultaneously.
|
Further Resources
Recommended reading: CANopen user guide: https://files.embeddedTS.com/pc104-peripherals/ts-can1/pdfs/ocera-canopen-ug.pdf
Usage with 3rd party devices
Please note that while efforts are made to follow the PC/104 specification this peripheral is not tested with third party SBCs or connected peripherals. This card is not guaranteed to operate as intended when third party PC104 peripherals or SBCs are connected.