TS-CAN1

From embeddedTS Manuals
Revision as of 17:37, 17 January 2022 by Lionel (talk | contribs) (Links auto-updated for 2022 re-branding ( https://files.embeddedarm.com/pc104-peripherals/ts-can1/ts-72xx-linuxr24/oceralincan_arm.tar.gz →‎ https://files.embeddedTS.com/pc104-peripherals/ts-can1/ts-72xx-linuxr24/oceralincan_arm.tar.gz https://cdn.embeddedarm.com/resource-attachments/ts-can1-schematic.pdf →‎ https://cdn.embeddedTS.com/resource-attachments/ts-can1-schematic.pdf https://files.embeddedarm.com/archive/Manuals/third-party/ts-can1_lincandoc-0.3.pdf →‎ https://files.embeddedTS...)
TS-CAN1
Ts-can1.jpg
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.


TS-7350, TS-7370, TS-7390, and TS-7800 I/O space starts at 0x600F_F800 physical address. For example, 0x150 I/O space is decoded at 0x600F_F950 pysical 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
Bit Description
0 LED (1=on, 0=off)
Base + 4 Page selection register RW
Bit Description
2-7 Reserved
0-1 Select one-of-four pages for SJA1000 access. This allows all 128 registers to be accessed using only 32 bytes of I/O space. Default to all zeroes. See SJA1000 I/O page selection register.
Base + 5 Mode control Register RW
Bit Description
7 Reserved
6 If set, it enables SJA1000 to appear in IO space location determined by mode bits 0-2. Also enables the page selection register (Base + 4) to be used.
5 If set, it allows the sharing of IRQ6 and IRQ7. It can only be set for TS ARM platforms and sharing can only be used for IRQ6 and IRQ7.
3-4 Reserved
2 MSB of 3 bit address select register.
1 Middle of 3 bit address select register.
0 LSB of 3 bit address select register. See SJA1000 I/O address selection.
Base + 6 Jumper Status R
Bit Description
6-7 Reserved
5 Jumper 5 (1=on, 0=off)
4 Jumper 4 (1=on, 0=off)
3 Jumper 3 (1=on, 0=off)
2 Jumper 2 (1=on, 0=off)
1 Jumper 1 (1=on, 0=off)
0 Reserved
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:

Driver for Linux

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:

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 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)

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:

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

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.


This Lincan driver only supports one TS-732 board simultaneously.

Further Resources

Recommended reading: CANopen user guide: https://files.embeddedTS.com/pc104-peripherals/ts-can1/pdfs/ocera-canopen-ug.pdf