CANbus User Manual
CANbus User Manual
Headquarters:
Raadhuislaan 27a
5341 GL OSS
THE NETHERLANDS
Postal address:
P.O. Box 627
5340 AP OSS
THE NETHERLANDS
Phone: +31-412-651055
Fax: +31-412-651050
Email: [email protected]
WEB: http://www.acq.nl
M360
CANbus M-module
User Manual
Version 1.0
M360 - CANbus M-module
User Manual Version: 1.0
All rights reserved. No part of this publication may be reproduced, transmitted, transcribed, stored in a
retrieval system, or translated into any language, in any form or by any means without the written
permission of AcQuisition Technology bv.
Disclaimer:
The information in this document has been carefully checked and is believed to be entirely reliable.
However, no responsibility is assumed for inaccuracies. AcQuisition Technology does not assume any
liability arising out of the application or use of any product or circuit described herein; neither does it
convey any license under its patent rights nor the rights of others. AcQuisition Technology products
are not designed, intended, or authorized for use as components in systems intended to support or
sustain life, or for any other application in which the failure of an AcQuisition Technology product
could create a situation where personal injury or death may occur, including, but not limited to
AcQuisition Technology products used in defence, transportation, medical or nuclear applications.
Should the buyer purchase or use AcQuisition Technology products for any such unintended or
unauthorized application, the buyer shall indemnify and hold AcQuisition Technology and its officers,
employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages and
expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal
injury or death associated with such unintended or unauthorized use, even if such claim alleges that
AcQuisition Technology was negligent regarding the design or manufacture of the part.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
CONTENTS
1. INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1. VALIDITY OF THE MANUAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2. PURPOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3. SCOPE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4. DEFINITIONS, ACRONYMS AND ABBREVIATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5. NOTES CONCERNING THE NOMENCLATURE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6. OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2. PRODUCT OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1. INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2. TECHNICAL OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4. FUNCTIONAL DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1. INTRODUCING CAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2. CAN CHARACTERISTICS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3. BLOCK DIAGRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.4. M-MODULE INTERFACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.5. READING AND W RITING DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.6. STATUS LEDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.7. RESET REGISTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.8. INTERRUPT GENERATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.9. MODULE IDENTIFICATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.10. CANBUS INTERFACES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.11. POWER SUPPLY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5. SOFTWARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.1. APIS SUPPORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.1.1. CONCEPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.1.2. API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.1.3. CODE GENERATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2. TYPE DEFINITIONS AND STRUCTURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3. THE M360 LIBRARY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3.1. TRANSMIT AND RECEIVE BUFFERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3.2. ACCEPTANCE FILTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3.3. ERROR COUNTERS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.3.4. ERROR CODES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.4. FUNCTION REFERENCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.5. SOFTWARE DISTRIBUTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 1 of 39
M360 - CANbus M-module
User Manual Version: 1.0
6. ANNEX ................................................................ 31
6.1. BIBLIOGRAPHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.2. COMPONENT IMAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.3. TECHNICAL DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.4. DOCUMENT HISTORY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.5. EXAMPLE CODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 2 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
1. INTRODUCTION
The contents of this manual is valid for M360 revision 3.x (hardware rev. 3, firmware rev. x).
The software library is based on APIS, AcQ Platform Interface Software version 2.0 and up.
1.2. PURPOSE
This manual serves as instruction for the operation of the M360 CANbus M-module, the connection of
peripheral devices, and the software library. Furthermore it gives the user additional information on
configuration of the assembly.
1.3. SCOPE
Detailed information concerning the individual assemblies (data sheets etc.) Are not part of this
manual. The bibliography can be found in the annex.
Hex numbers are marked with a leading “0x”-sign: for example: 0x20 or 0xff.
The jumpers are designated by a 'J', and a serial number. When specifying whether a jumper should
be connected or removed it is referred to solely by this designation if it has only one position (e.g., 'J5
connected'). However, if the jumper has more than one position, it is also indicated which pins are
connected to each other (e.g. 'J8,1-2'). Pin 1 of a jumper is always marked in the configuration
diagram.
In some illustrations jumpers are shown merely for purposes of orientation. In this case they are
indicated with a dotted line. Their correct setting is described in another chapter.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 3 of 39
M360 - CANbus M-module
User Manual Version: 1.0
1.6. OVERVIEW
In chapter two a short description of the M360 CANbus M-module can be found. The next chapter
covers the installation and setup of the module as well as the connection of the CANbus lines. In
chapter 4 the functionality of the M360 CANbus M-module is described in detail. AcQ provides an
APIS based ANSI C library for the M360 CANbus M-module, the software is described in chapter 5.
Finally this document contains an Annex containing a bibliography, component image, technical data,
document history and a programming example.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 4 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
2. PRODUCT OVERVIEW
2.1. INTRODUCTION
The M360 CANbus Controller is designed as a plug-on module with a M-module interface based on
the SJA1000, a highly integrated stand-alone controller for the Controller Area Network (CAN).
CAN is used within automotive and general industrial environments. The M360 contains all necessary
hardware for a high performance serial network communication. The M360 performs all the functions
of the physical and data-link layers.
The use of the M360 CAN bus controller in an industrial environment, results in a reduction of wiring
harness and an enhanced diagnostic and supervisory capability.
The software library is available, so an application can be programmed without knowing something of
the hardware.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 5 of 39
M360 - CANbus M-module
User Manual Version: 1.0
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 6 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
The hardware is shipped in an ESD protective container. Before unpacking the hardware, make sure
that this takes place in an environment with controlled static electricity. The following
recommendations should be followed:
! Make sure your body is discharged to the static voltage level on the floor, table and system
chassis by wearing a conductive wrist-chain connected to a common reference point.
! If a conductive wrist-chain is not available, touch the surface where the board is to be put
(like table, chassis etc.) before unpacking the board.
! Leave the board only on surfaces with controlled static characteristics, i.e. specially designed
anti static table covers.
! If handling the board over to another person, touch this persons hand, wrist etc. to discharge
any static potential.
IMPORTANT: Never put the hardware on top of the conductive plastic bag in which the hardware is
shipped. The external surface of this bag is highly conductive and may cause rapid
static discharge causing damage. (The internal surface of the bag is isolating.)
Inspect the hardware to verify that no mechanical damage appears to have occurred.
Please report any discrepancies or damage to your distributor or to AcQuisition
Technology immediately and do not install the hardware.
To work properly, the M360 CANbus controller module must be configured according to the particular
circumstances.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 7 of 39
M360 - CANbus M-module
User Manual Version: 1.0
On both ends of the CAN bus the physical line must be terminated by a 124 Ohm resistance.
! Place jumper J10, if the M360 is at the end of the physical line.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 8 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
The M360 features a 9 pole D-sub connector for interfacing with the CANbus. The M360 can also be
connected with the CANbus through the 24 pole female header.
- Reserved 1, 4, 5, 8 3, 13...24
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 9 of 39
M360 - CANbus M-module
User Manual Version: 1.0
3.4. SOFTWARE
M360 Example software is APIS based, therefore APIS support for the target platform is required for
code generation.
Code generation is platform dependent, for information on building the software please refer to the
release notes of APIS for the target platform and the APIS Programmer's Manual.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 10 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
4. FUNCTIONAL DESCRIPTION
The Controller Area Network (CAN) is a data communication network designed to fit distributed
real-time control applications. It was originally developed and applied by the automotive industry to
solve the cabling problem inside vehicles.
CAN is a serial communications protocol, originally specified by Bosch. The protocol handles multiple
processors. Each of these processors can send and receive priority messages. CAN nodes request
data by sending a Remote Frame message; the requested data is sent via a Data Frame with the
same message ID. Messages are acknowledged by sending an ACK message.
Transmitted messages pass to all nodes on the bus (multi-cast), all of which take the message frame.
The received messages are then filtered based on the message IDs.
CAN has only four message types: Data Frame, Remote Frame (request data), Error Frame (signals
a local node error), and an Overload Frame (extend delay before next frame). As CAN nodes place
requests, the highest priority one take the bus (priority is based on recessive vs dominant bits, where
the dominant bits override the recessive bits).
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 11 of 39
M360 - CANbus M-module
User Manual Version: 1.0
The M-module interface databus is 8 bits wide and supports low-byte transfers (d0..d7). The local bus
interface to the CAN controller is based on the Intel principals with a multiplexed address/data bus.
Chip select signals, interrupt lines, enable lines and signals needed for identification readout are
derived from the M-module interface by PLD's (U3 and U4).
A 16MHz crystal (default) or the M-module bus clock provides the clock signal.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 12 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
The addressable registers of the M360 are displayed in the following table.
Offset is the value which must be added to the (even) base address of the module.
Reading or writing to the SJA1000 registers is done by accessing one of the registers from the table
above. For a detailed description of the registers, please refer to the specification of the SJA1000
CAN controller.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 13 of 39
M360 - CANbus M-module
User Manual Version: 1.0
The two status LEDs at the M360 front can be turned off and on by writing to the front LED register
(offset 0x40).
The GREEN LED is on when a ‘1' is written to bit 0 of the register.
The RED LED is on when a ‘1' is written to bit 1 of the register.
After power up, the CAN controller is kept in reset state. Writing 0x01 to the reset register (offset
0x80) will release the reset.
Writing the sequence 0x00 0x01 will reset the hardware CAN controller.
The interrupt register (offset 0x07) allows the identification of an interrupt source. When one or more
bits of this register are set, the M360 will generate an interrupt to the host. The interrupt service
routine must acknowledge the interrupt request by reading this register.
For a detailed description, please refer to the specification of the SJA1000 CAN controller.
With revision 2.1 of the M-module specification a new feature is added, called ‘Module Identification’.
The idea behind the feature is that a universal piece of software should be able to determine what
module (and revision etc.) Is on a specific location. In order to do this an EEPROM type 93c06 (16x16
bits) is implemented.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 14 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
The M360 M-module contains a PCA82C250T CAN bus transceiver. This is the interface between the
CAN controller and the physical bus. It is fully compatible with the ISO/DIS 11898 standard and
primarily intended for high speed applications up to 1 Mbit/s.
The M360 M-module also contains a SN75176B differential bus transceiver. This meets the EIA
Standards RS-422-A and RS-485 and CCITT Recommendations V.11 and X.27.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 15 of 39
M360 - CANbus M-module
User Manual Version: 1.0
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 16 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
5. SOFTWARE
This chapter describes the example software that is available for the M360 CANbus M-module. The
example software is available in ANSI-C source code and consists mainly of an M360 function library
which provides functions for easy access to the M360 and a demo program which illustrates the
usage of the software library.
The M360 library functions are APIS based, physical accesses and interrupt support are handled by
APIS, AcQ Platform Independent Interface Software. The next section contains general information
on APIS, for detailed information please refer to the APIS Programmer’s Manual.
AcQ produces and supports a large number of standard M-modules varying from networking and
process I/O to motion control applications. Physically, the M-modules are supported by a large
number of hardware platforms: VMEbus, PCI, CompactPCI as well as a wide variety of operating
systems: OS-9, Windows NT, Linux etc.
APIS offers a way to program platform independent applications, example- and test software for
controlling hardware. Application software written for APIS only needs re-compiling for a particular
platform and is operational with little effort (provided that the application is operating system
independent).
5.1.1. CONCEPT
Hardware accesses to registers and memory are handled by APIS. Some minor operating system
dependent functions frequently used in hardware related software, such as interrupt handling and a
delay function are also provided by APIS.
APIS platform support consists of an Application Programming Interface in the form of definition files
coded in ANSI-C and platform dependent modules e.g. source files, libraries and/or drivers.
In the most simple outline, a platform dependent APIS module consist of nothing more then macro
definitions in which APIS calls are substituted by direct hardware accesses. But in most cases an
APIS module will consist of a library with interface routines and in some implementations a device
driver is needed for interaction with the operating system.
5.1.2. API
The Application Programming Interface for APIS is implemented in two ANSI-C coded definition files:
apis.h which contains general definitions and platform_apis.h which contains platform specific
definitions and references to the APIS function calls.
The application source file must include the APIS header file apis.h. Porting of the application to a
platform, consists of re-compiling the source code with a defined pre-processor macro for selection of
the used platform. The APIS header file contains generic APIS definitions and includes a platform
specific header file according to the platform selection macro.
API calls are translated to the platform specific calls in the APIS header file and the platform specific
definition file platform_apis.h (platform is a name that identifies a hardware and operating system
combination, e.g. i4000os9).
The macro PLATFORM must be defined, either via a pre-processor definition provided at compile
time or via a macro-definition in the application source.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 17 of 39
M360 - CANbus M-module
User Manual Version: 1.0
APIS based example software is available in ANSI-C source code. Source code files must be
compiled with the pre-processor definition PLATFORM set to a valid value, conforming the target
platform. Building of the example software for the M360 is platform dependent, for details refer to the
release notes of the APIS support package of the target platform and the APIS Programmer’s
Manual.
Examples of APIS supported platforms are i4000os9, i2000dos, i3000win etc.
The table below contains a list and description of all types and structures used in the M360 example
software (standard ANSI-C types are not listed).
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 18 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
The library is based on APIS, and contains 6 functions. These functions are described in the next
section. Below the main aspects of the library will be discussed.
The library contains a transmit and a receive buffer. The buffers are based on a FIFO principle and
each one has 32 places to store CAN messages.
When the M360 CANbus M-module receives a message, it will be stored in the receive buffer. If the
receive buffer is full, the oldest message will be removed and the newest will be stored in the buffer.
The oldest message of the buffer will be read with the read function of the library.
The write function examines the M360 CANbus M-module. If the module is not busy, the message will
be transmitted immediately. Otherwise the message will be stored in the transmit buffer. When the
buffer is full the write function will NOT store the message in the transmit buffer and returns an
appropriated error code. When the M360 CANbus M-module is not busy anymore, the library is taking
care of the transmitting of all messages in the transmit buffer. The oldest message of the buffer will
be transmitted first.
The M360 CANbus M-module is equipped with a acceptance filter, which allows an automatic check
of the identifier and data bytes. Using these effective filtering methods, messages or a group of
messages not valid for a certain node can be prevented from being stored in the receive buffer. This
way it is possible to reduce the processing load of the host controller.
The filter is controlled by the acceptance code and mask. The received identifier is compared bitwise
with the acceptance code. The acceptance mask defines the bit positions, which are relevant for the
comparison (0 = relevant, 1 = not relevant). To accept a message all relevant receive identifier bits
have to match the respective bits of the acceptance code.
Note: Only the 8 most significant bits of the identifier of the CAN message are compared to the
values of the acceptance code and mask.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 19 of 39
M360 - CANbus M-module
User Manual Version: 1.0
The library contains 4 error counters and each one will be increased when a corresponding error
occurs on the M360 CANbus M-module.
If the execution of a function is successful the function returns zero, if not the function returns an
APIS error code. APIS error codes are 16-bit wide and are referred to with a symbolic name:
APIS_Exxxxxxxx, where xxxxxxxx is a short description of 8 characters max.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 20 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
Description: A physical path will be opened for the requested path. The path is system dependent
and can be hardware address, port ID or an index number of some kind. The interrupt
service routine will be installed. This routine also initializes the M360 CANbus
M-module. It initializes the receive buffer and transmit buffer, and resets the error
counters.
Returns: APIS_NOERR
The function executed successful.
APIS_Exxxxxxxx
There was an error during the execution of this function.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 21 of 39
M360 - CANbus M-module
User Manual Version: 1.0
Description: A previously opened hardware path is closed. This routine reinitializes the M360
CANbus M-module. It removes the receive buffer and transmit buffer and resets the
error counters. The interrupts will be disabled and the interrupt service routine will be
removed.
Returns: APIS_NOERR
The function executed successful.
APIS_Exxxxxxxx
There was an error during the execution of this function.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 22 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
Description: This routine reads a received CAN message from the receive buffer. When there are
no received CAN messages, the routine will return an "Buffer empty" error-code.
When the receive buffer has an overflow, the routine will return an "Buffer overflow"
error-code.
Returns: APIS_NOERR
The function executed successful.
APIS_Exxxxxxxx
There was an error during the execution of this function.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 23 of 39
M360 - CANbus M-module
User Manual Version: 1.0
Description: This routine writes a CAN message to the M360 CANbus M-module. When the M360
is busy, the message will be written to the transmit buffer. This message will be
transmitted when the M360 is not busy. When the transmit buffer is full, the routine
will return an "Buffer full" error-code.
Returns: APIS_NOERR
The function executed successful.
APIS_Exxxxxxxx
There was an error during the execution of this function.
msg.id = 0x200;
msg.type = DATA;
msg.length = 8;
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 24 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
Description: This routine performs control commands with the information stored in the control
parameters. Or gives information back through these control parameters. The
following control commands will be available:
Command Parameters Description
SET_BAUDRATE pParm->baudrate This command sets the baud rate of
the CAN bus. This can be 10k, 20k,
50k, 125k, 250k, 500k, 800k or
1Mbit/s.
GET_BAUDRATE pParm->baudrate This command returns the
established baud rate of the CAN
bus.
SET_ACCFLT pParm->accFlt.code This command sets the acceptance
pParm->accFlt.mask code and mask of the M360 CAN
bus M-module.
GET_ACCFLT pParm->accFlt.code This command returns the
pParm->accFlt.mask established acceptance code and
mask.
GET_ERRCNT pParm->errCnt.overflow This command returns the error
pParm->errCnt.overrun counters of the M360 CAN bus
pParm->errCnt.busOff M-module.
pParm->errCnt.txRx
RESET_IRQF pParm->irqFlags This command resets the interrupt
flags of the M360 CAN bus
M-module.
GET_IRQF pParm->irqFlags This command returns the interrupt
flags of the M360 CAN bus
M-module.
GET_MODID pParm->modId.modNumber This command returns the module
pParm->modId.majorHwRev identification and the hardware- and
pParm->modId.minorHwRev software-revision.
pParm->modId.majorSwRev
pParm->modId.minorSwRev
FLUSH_BUF - This command clears the receive
and transmit buffers.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 25 of 39
M360 - CANbus M-module
User Manual Version: 1.0
Returns: APIS_NOERR
The function executed successful.
APIS_Exxxxxxxx
There was an error during the execution of this function.
parm.baudrate = CAN_20K;
result = m360_ioctrl ( handle, SET_BAUDRATE, &parm);
if (result != APIS_NOERR)
{
/* Do something with the error code. */
}
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 26 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
Description: Suspend current process. When a signal is received that is sent by an APIS interrupt
service routine, this function returns with APIS_NOERR as result code. If a signal is
received not caused by APIS (e.g. keyboard interrupt), the function returns with
APIS_ESIG as result code. The interrupts received before m360_waitforirq is called
are not missed.
Arguments: .
No parameters.
Returns: APIS_NOERR
The function executed successful.
APIS_ESIG
There was an interrupt received, but not caused by APIS.
APIS_Exxxxxxxx
There was an error during the execution of this function.
printf ("Waiting...\n");
do
{
result = m360_waitforirq();
m360_ioctrl ( handle, GET_IRQF, &parm);
} while ((result == APIS_NOERR) &&
((parm.irqFlags & M360_RX_IRQ) != M360_RX_IRQ));
if (result == APIS_ESIG)
{
/*
* A signal is received, but not caused by APIS
* (e.g. keyboard interrupt).
*/
}
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 27 of 39
M360 - CANbus M-module
User Manual Version: 1.0
if (msg.length > 8)
{
msg.length = 8;
}
printf ("Data: ");
for (idx = 0; idx < msg.length; idx++)
{
printf ("0x%02x ", msg.data[idx]);
}
}
else
{
printf ("Type: request ");
}
printf ("\n");
}
else
{
/* Do something with the error code. */
}
}
else
{
/* Do something with the error code. */
}
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 28 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
File Description
The software is distributed on a 3.5" 1,44MB PC-HD format floppy disk. Other media are available on
request.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 29 of 39
M360 - CANbus M-module
User Manual Version: 1.0
M360 example software is APIS based, therefore APIS support for the target platform is required for
code generation.
The following figure is an example of the M360 software integrated in the APIS environment with as
target platform the i4000/OS-9.
Code generation is platform dependent, for information on building the software please refer to the
release notes of the target platform and the APIS Programmer’s Manual.
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 30 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
6. ANNEX
6.1. BIBLIOGRAPHY
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 31 of 39
M360 - CANbus M-module
User Manual Version: 1.0
Interrupt:
Interrupt of type A, software-end-of-interrupt.
Connection:
To base-board via 40 pole M-module interface.
To peripheral on the front via 9 pole D-sub connector, or via 24 pole header connector.
Power supply:
+5VDC ±10%, typical 175mA (from M-module baseboard, galvanic isolation voltage supply
from local DC/DC converter).
Temperature range:
Operating: 0..+60EC.
Storage : -20..+70EC.
Humidity:
Class F, non-condensing.
! Revision 1.0
First release, this release replaces the Hardware Manual Revision 3.0 and Software
Manual Revision 3.0.
/*
* File: m360main.c
* Revision: 1.0
* Date: 11-01-00
* Authors: MQ
* ----------------------------------------------------------------------
* Demo application
*
* The file contains the main function of the demo application of
* the M360 CANbus M-module.
*
* ----------------------------------------------------------------------
* Copyright 2000 by AcQuisition Technology bv.
* All Rights Reserved
* Reproduced Under License
*
* This source code is the proprietary confidential property of
* AcQuisition Technology bv., and is provided to the licensee
* for documentation and educational purposes only. Reproduction,
* publication, or any form of distribution to any party other than
* the licensee is strictly prohibited.
* ----------------------------------------------------------------------
* Edition History
*
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 32 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "../LIB/m360lib.h"
/* Forward declarations */
void usage( char *pname );
void printError ( int errorCode );
/*
* Function: main
*
* Description: This is the main routine of the Demo application.
*
* Parameters: int argc,
* char *argv[]
* Parameters throughput
*
* Return: 0
* Always zero.
*
*/
int main (int argc, char *argv[])
{
int idx1, idx2;
int readMsg = 0, writeMsg = 0;
UINT32 base = 0;
UINT32 pass = 1, passed = 0;
int result;
APIS_PATH path = 0;
M360_HANDLE handle;
ACC_FLT accFlt = {0xff, 0xff};
UINT16 baudrate = CAN_1000K;
CAN_MSG msg;
IOC_PRM parm;
int data[9];
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 33 of 39
M360 - CANbus M-module
User Manual Version: 1.0
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 34 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
if (readMsg == writeMsg)
{
/* only read OR write */
usage(argv[0]);
}
passed++;
} while (passed < pass);
}
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 35 of 39
M360 - CANbus M-module
User Manual Version: 1.0
do
{
printf ("Waiting...\n");
do
{
/* Wait for an interrupt */
result = m360_waitforirq();
m360_ioctrl ( handle, GET_IRQF, &parm);
/* Is it ours? */
} while ((result == APIS_NOERR) &&
((parm.irqFlags & M360_RX_IRQ) != M360_RX_IRQ));
if (result == APIS_ESIG)
{
/*
* A signal is received, but not caused by APIS
* (e.g. keyboard interrupt).
*/
passed = pass;
}
else if ((parm.irqFlags & M360_RX_IRQ) == M360_RX_IRQ)
{
/* The M360 M-module has received a message. */
/* Reset the receive interrupt flag */
parm.irqFlags = M360_RX_IRQ;
m360_ioctrl ( handle, RESET_IRQF, &parm);
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 36 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
{
/* The waitforirq function goes wrong */
/* Do something with the error code. */
printError (result);
}
} while (passed < pass);
}
return 0;
}
/*
* Function: usage
*
* Description: Displays the usage of this application and closes it.
*
* Parameters: char *pName
* Application name.
*
* Return: 0
* Always zero.
*
*/
void usage (char *pName)
{
printf("Syntax: %s [<opts>]\n", pName);
printf("Options:\n");
printf("\t-p=<path> module base path in hex (default = 0)\n");
printf("\t-r=<pass> display incoming CAN messages or\n");
printf("\t-w=<pass> send a CAN message\n");
printf("\t-b=<baudrate> set the baudrate: 1 = 10 Kbits/s\n");
printf("\t 2 = 20 Kbits/s\n");
printf("\t 3 = 50 Kbits/s\n");
printf("\t 4 = 125 Kbits/s\n");
printf("\t 5 = 250 Kbits/s\n");
printf("\t 6 = 500 Kbits/s\n");
printf("\t 7 = 800 Kbits/s\n");
printf("\t 8 = 1 Mbits/s (default)\n");
printf("\t-? this help\n");
exit(0);
}
/*
* Function: printError
*
* Description: Displays the meaning of the error code.
*
* Parameters: int errorCode
* An error number.
*
* Return: .
* None.
*
*/
void printError (int errorCode)
{
switch (errorCode)
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 37 of 39
M360 - CANbus M-module
User Manual Version: 1.0
{
case APIS_ENOTSUP:
printf ("not supported function\n");
break;
case APIS_EPARAM:
printf ("bad parameter\n");
break;
case APIS_EPARMOR:
printf ("parameter out of range\n");
break;
case APIS_EPERMIT:
printf ("no permission\n");
break;
case APIS_EWIDTH:
printf ("invalid data width\n");
break;
case APIS_EGOS:
printf ("general operating system error\n");
break;
case APIS_EINVREQ:
printf ("invalid request\n");
break;
case APIS_ENOMEM:
printf ("no memory available\n");
break;
case APIS_EMODERR:
printf ("APIS support module not found\n");
break;
case APIS_ENOIRQH:
printf ("no interrupt handler installed\n");
break;
case APIS_ENIRQIU:
printf ("interrupt in use\n");
break;
case APIS_EINVPATH:
printf ("invalid path ID\n");
break;
case APIS_ESIG:
printf ("signal error\n");
break;
case APIS_EINVMOD:
printf ("invalid module\n");
break;
case APIS_EINVDRV:
printf ("invalid driver\n");
break;
case APIS_EOPENDEV:
printf ("error opening device\n");
break;
case APIS_ELOCK:
printf ("device is already in use\n");
break;
case APIS_EINCDEV:
printf ("incorrect device\n");
break;
case APIS_EPCIERR:
printf ("PCI error\n");
break;
case APIS_EINVHND:
printf ("invalid handle\n");
break;
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Page 38 of 39 Oss, The Netherlands
M360 - CANbus M-module
User Manual Version: 1.0
case APIS_EINVOFF:
printf ("invalid offset\n");
break;
case APIS_EINTRPT:
printf ("interrupt error\n");
break;
case APIS_EFIFOEMP:
printf ("fifo buffer is empty\n");
break;
case APIS_EFIFOFULL:
printf ("fifo buffer is full\n");
break;
case APIS_EFIFOFLOW:
printf ("fifo buffer has an overflow\n");
break;
}
}
/* End of file */
AcQuisition Technology bv
P.O. Box 627, 5340 AP
Oss, The Netherlands Page 39 of 39