CAN Node using HCS12

Similar documents
CAN Protocol Implementation

Chapter 1 Freescale s Scalable Controller Area Network (S12MSCANV2)

MSCAN Block Guide V03.01

Hello, and welcome to this presentation of the STM32 Low Power Universal Asynchronous Receiver/Transmitter interface. It covers the main features of

Application Note. Introduction. AN2255/D Rev. 0, 2/2002. MSCAN Low-Power Applications

ECE 4510/5530 Microcontroller Applications Week 11

ECE 4510 Introduction to Microprocessors. Chapter 13

Controller Area Network

DCB1M - Transceiver for Powerline Communication

CANmodule-IIx. Version 2.7.0

CANmodule-III. Version Datasheet

Engineer-to-Engineer Note

Freescale Semiconductor, I. SECTION 13 CAN 2.0B CONTROLLER MODULE (TouCAN)

Concepts of Serial Communication

Hello, and welcome to this presentation of the STM32 I²C interface. It covers the main features of this communication interface, which is widely used

Communication Networks for the Next-Generation Vehicles

Computation of CAN Bit Timing Parameters Simplified

PIC-I/O Multifunction I/O Controller

Using the MPC5777M MCAN Module to Exchange CAN FD Messages

Course Introduction. Purpose. Objectives. Content. Learning Time

RL78 Serial interfaces

MCP2510. MCP2510 Rev. AA Silicon Errata Sheet. 3. Module: Error Flags. 1. Module: Configuration Mode State Machine. 4. Module: Bus Timing Logic

CAN protocol enhancement

Device: MOD This document Version: 1.0. Matches module version: v3 [29 June 2016] Date: 23 October 2017

Using CAN Arbitration for Electrical Layer Testing

VORAGO VA108x0 I 2 C programming application note

Serial/CAN-Gateway. SerCAN-ARM7/RMD. User Manual. Thomas Wünsche

BOSCH. CAN Specification. Version , Robert Bosch GmbH, Postfach , D Stuttgart

CAN / RS485. Product Description. Technical Reference Note. Interface Adapter. Special Features

Tutorial Introduction

M68HC08 Microcontroller The MC68HC908GP32. General Description. MCU Block Diagram CPU08 1

The House Intelligent Switch Control Network based On CAN bus

Recommended readings

Hello, and welcome to this presentation of the STM32 Universal Synchronous/Asynchronous Receiver/Transmitter Interface. It covers the main features

High-Speed CAN Transceiver with Partial Networking

An Introduction to CAN by Peter Bagschik (I+ME ACTIA)

CONTROLLER AREA NETWORK (CAN)

ec-test-mate Hardware Reference Manual

ZigBee Compliant Platform 2.4G RF Low Power Transceiver Module for IEEE Standard. DATA SHEET Version B

EASY219 / IEC CANopen Master / Slave

CAN (Controller Area Network) Physical Layer

UNIT - II PERIPHERAL INTERFACING WITH 8085

MCS-51 Serial Port A T 8 9 C 5 2 1

CANmodule-IIIx. Version Datasheet

Serial Communication. Simplex Half-Duplex Duplex

CAN in Space workshop

Today. Last Time. Motivation. CAN Bus. More about CAN. What is CAN?

GW-7238D J1939 to Modbus TCP Server / RTU Slave Gateway

The Controller Area Network (CAN) Interface

RF900 LoRa Telemetry module V1.0

INTEGRATED CIRCUITS DATA SHEET. SJA1000 Stand-alone CAN controller Nov 04. Preliminary specification File under Integrated Circuits, IC18

MOS INTEGRATED CIRCUIT

QBridge. I2C, SPI, CAN Control Software User s Manual. Date: Rev 1.3

Design and Implementation of CAN Bus Controller on FPGA

The Atmel ATmega168A Microcontroller

XR16M V TO 3.63V HIGH PERFORMANCE OCTAL UART WITH 16-BYTE FIFO

DS Digital Signal Controller

YASP Yet Another Scalable Protocol

AvnetCore: Datasheet

TPMC Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

Positioning Controller

WM1030 Rev Introduction. Ultra low power DASH7 Modem. Applications. Description. 868 / 915 MHz. Features. WIZZILAB Technical datasheet 1/10

EP A1 (19) (11) EP A1 (12) EUROPEAN PATENT APPLICATION. (43) Date of publication: Bulletin 2012/45

Page 1 of 11 Version 1.2 Release Date: PenMount PM2204 PCI Controller Board Data Sheet. Table of contents

UART Register Set. UART Master Controller. Tx FSM. Rx FSM XMIT FIFO RCVR. i_rx_clk o_intr. o_out1 o_txrdy_n. o_out2 o_rxdy_n i_cs0 i_cs1 i_ads_n

Module Introduction. PURPOSE: The intent of this module is to explain MCU processing of reset and interrupt exception events.

TPMC Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

Learn how to communicate

Supported Device Family 1. Supported User Interfaces. Resources 3. Documentation. Design Files. Constraints File

SH1030 Rev Introduction. Ultra low power DASH7 Arduino Shield Modem. Applications. Description. 868 MHz. Features

CHAPTER 5 REGISTER DESCRIPTIONS

Lab 8 (ETH): Control Area Network

FEATURES AACK 1 CGP2 2 AINT 3 CSTAT 4 SCANSHIFT 5 ARX2N 6 ARX3P 7 VDD 8 GND 9 ARX3N 10 ARX4P 11 ARX4N 12 ARX5P 13 ARX5N 14 ARX6P 15 ARX6N 16.

TCP Channel Serial Interface RS232/RS422. Version 1.0. User Manual. Issue August 2014

TMS470R1x Class II Serial Interface B (C2SIb) Reference Guide

Chapter 10 Sections 1,2,9,10 Dr. Iyad Jafar

TPMC810. Isolated 2x CAN Bus. Version 1.1. User Manual. Issue June 2009

SCI Serial Communication Interface

FlexRay controller. Author: Martin Paták

ISSN:

AVR XMEGA Product Line Introduction AVR XMEGA TM. Product Introduction.

Controller area network

Sequential Event Recorder

PL1167. Low Power High Performance Single Chip 2.4GHz Transceiver. Product Description: Key Features: Applications: Pin Configuration:

Welcome to this presentation of the STM32 direct memory access controller (DMA). It covers the main features of this module, which is widely used to

Asynchronous Data Transfer

BOOST YOUR SYSTEM PERFORMANCE USING THE ZILOG ESCC CONTROLLER

CAN bus communication module

TSS463C. VAN Data Link Controller with Serial Interface. Features. Description

CF-850/F1K-144-S Hardware Manual

CF-850/F1KM-176-S Hardware Manual

PCI-HPDI32A-COS User Manual

COMP2121: Microprocessors and Interfacing

Gryphon Hardware Information: Dual SJA1000 Fault Tolerant CAN card

Serial Communications

TIP SERCOS IP with 2 Encoder Interfaces. User Manual. The Embedded I/O Company. Version 1.0. Issue 1.3 September 2006 D

PROFIBUS DP/CAN Gateway PCA-100. User Manual

Dallas Semiconductor DS1307 Real Time Clock. The DS 1307 is a real-time clock with 56 bytes of NV (nonvolatile)

The Atmel ATmega328P Microcontroller

MicroBolt. Microcomputer/Controller Featuring the Philips LPC2106 FEATURES

Transcription:

CAN Node using HCS12 Ketan Kulkarni, Siddharth Dakshindas Electrical and Computer Engineering Department School of Engineering and Computer Science Oakland University, Rochester, MI e-mails: krkulkarni@oakland.edu, spdakshindas@oakland.edu Abstract The objective of this project is to demonstrate CAN capabilities of HCS12.A network of 2 CAN nodes will be created using 2 Dragon-12 boards. The MSCAN12 module will be set at 125 KHz baud rate. Both the boards will be communicating on different IDs. I. INTRODUCTION The controller area network (CAN) has been a robust serial communication protocol since the past 3 decades. CAN vastly reduces complexity and decreases wiring considerably. CAN specifications were later published and most automotive micro-controllers now support CAN 2.0A and 2.0B. The HCS12 CAN Module provides the following features: 1. Full implementation of the CAN 2.0A/B protocol. 2. Five receive buffers with FIFO storage scheme. 3. Three transmit buffers with internal prioritization. 4. Programmable wake-up functionality with integrated low-pass filter. 5. Three low-power modes: sleep, power-down, and MSCAN12 enable. 6. Programmable loopback mode supporting selftest operation. 7. Clock source coming from either E-clock or oscillator clock. 8. Internal time for time stamping of received and transmitted message. 9. Global initialization of configuration registers. The CAN protocol specifies the lowest two layers of the ISO seven-layer model: data link and physical layers. CAN is a message-based protocol with an identifier embedded in each message. The identifier helps the node to decide whether it is to receive and process the message. Also, in case of 2 messages on the bus at the same time, the identifier helps in arbitration. The lower the value of the message identifier, higher its priority. Since an address is not used in the CAN system, there is no need to reconfigure the system whenever a node is added to or deleted from a system. The CAN specifications use the terms "dominant" bits and "recessive" bits where dominant is a logical 0 (actively driven to a voltage by the transmitter) and recessive is a logical 1 (passively returned to a voltage by a resistor). The idle state is represented by the recessive level (Logical 1). If one node transmits a dominant bit and another node transmits a recessive bit then the dominant bit "wins" (a logical AND between the two). This is how, it is easy for message arbitration mechanism to decide the priority of the messages. During arbitration, each transmitting node monitors the bus state and compares the received bit with the transmitted bit. If a dominant bit is received when a recessive bit is transmitted then the node stops transmitting (i.e., it lost arbitration). Arbitration is performed during the transmission of the identifier field. Each node starting to transmit at the same time sends an ID with dominant as binary 0, starting from the high bit. As soon as their ID is a larger number (lower priority) they will be sending 1 (recessive) and see 0 (dominant), so they back off. At the end of ID transmission, all nodes but one have backed off, and the highest priority message gets through unimpeded. The CAN messages are transmitted and received in terms of frames. Bits in the frame are represent in fields and each field has a special function. Figure 2 Standard CAN Frame Figure 1 Layered Architecture of CAN

The HCS12 s MSCAN12 module supports CAN 2.0A/B. It supports standard and extended data frames as well as remote frames with a programmable bit rate up to 1 Mbps2. The MSCAN12 has a triple transmit buffer scheme which allows multiple messages to be set up in advance and achieve an optimized performance. Received messages are stored in a five stage input FIFO. The module has a configurable hardware identifier filter which may be applied to incoming messages. A successful transmission or a message reception with a matching identifier will be flagged and can generate an interrupt request to the CPU. MSCAN12 block diagram: Figure 3 MSCAN12 block diagram An HCS12 member may have up to five CAN modules and each CAN module occupies 4 bytes of memory space. The MSCAN register organization is shown in Figure below II. METHODOLOGY A. Setup & test MSCAN12 module in loop back mode: Prior to connecting 2 boards together to communicate on CAN, the MSCAN12 configuration can be tested in loopback mode. Since the module is configured in loop back mode, the MCU treats its own transmitted message as a message received from a remote node. This mode enables self-test operation, independent from any physical layer implementation. The following steps are followed to setup and test MSCAN12 module: 1. Enter Initialization Mode by setting CAN0CTL0 = 0x01 2. Set MSCAN in loop back mode by setting CAN0CTL1 = 0xA0 3. Setup the sync jump width, TSEG1 and TSEG2 by setting the registers CAN0BTR0 and CAN0BTR1 4. Setup the receiver filters to receive ID 0x100 by setting the register CAN0IDAC 5. Check if the transmit buffer is full (CAN0TFLG) and if not full then load the ID in the IDR register (CAN0TXIDR0) 6. Set the Data length, priority and then fill the transmit buffer CAN0TFLG 7. Setup receive message ISR which get triggered when message is received. Inside the ISR, receive the data by reading the CAN0RXDSR0 register. The data that is transmitted from the Tx bus is received in the receive buffer. We confirmed that the messages that were being transmitted were being received at each node. After this, we connected the 2 boards together by using 2 wires. B. Transmitting and receiving data to/from other board. After successful communication in loop back mode we connected the two boards. Now here in this part Board one will transmit as well receive data and other board will also transmit and receive the data. For this we have connected two boards using wires. (CAN_HI => CAN_HI & CAN_LOW => CAN_LOW) Now perform the same Initialization for the mode with loopback self-test disabled. The following steps are followed to setup and test MSCAN12 module: 1. Enter Initialization Mode by setting CAN0CTL0 = 0x01 2. Set MSCAN in loop back mode by setting CAN0CTL1 = 0x80 3. Setup the sync jump width, TSEG1 and TSEG2 by setting the registers CAN0BTR0 and CAN0BTR1 4. Setup the receiver filters to receive ID 0x100 by setting the register CAN0IDAC 5. Check if the transmit buffer is full (CAN0TFLG) and if not full then load the ID in the IDR register (CAN0TXIDR0) 6. Set the Data length, priority and then fill the transmit buffer CAN0TFLG 7. Setup receive message ISR which get triggered when message is received. Inside the ISR, receive the data by reading the CAN0RXDSR0 register.

The data that is transmitted from the Tx bus is received in the receive buffer. The normal mode can be broken up into 3 distinct steps Initialization, Message Reception and Message Transmission. Below, the configuration of each register in every steps is discussed. MSCAN Control Registers: For CAN Initialization: 1) CAN0CTL0 = 0x01; // Put MSCAN Module in Initialization Mode 2) CAN0CTL1 = 0x80; //enable CAN 3) CAN0BTR0 = 0xC3; // Synch Jump = 4 Tq clock Cycles, prescalar = 4 4) CAN0BTR1 = 0x3A; // Set Number of samples per bit, TSEG1 and TSEG2 The bit time is determined by the oscillator frequency, the baud rate prescaler, and the number of time quanta (tq) clock cycles per bit. The bit time is given by the following expression: 5) CAN0IDAC = 0x10; // Set four 16-bit Filters 8) CAN0TBSEL: /* Select lowest empty buffer */ C. Setup cyclic messages to be sent every 10ms & 15ms using Real Time Interrupt (RTI): CAN messages can be sent cyclically after a fixed interval. We decided this interval to be 10ms & 15ms. Thus 2 messages with IDs 0x100 and 0x200 will be sent from Board A to Board B and Board B to Board A respectively. The delay can be generated using the Real Time Interrupt (RTI). From calculations, we found out that when RTICTL = 0x49, for an 8 MHz oscillator, a period of 10.24ms can be achieved and RTICTL = 0x4F creates a period of about 15ms. When the ISR is executed, the Data length, ID and data is transmitted, the Transmit function is invoked thus transmitting the messages every 10ms and 15ms (approximately). D. Setup Dynamic values to be sent from both sides To achieve the dynamic values in CAN communication Board A will transmit value of VARISTOR and it is displayed on the LCD of board B. Board B will transmit the status of the DIP switch which will be displayed on boards A. Thus 2 messages with IDs 0x100 and 0x200 will be sent from Board A to Board B and Board B to Board A respectively. III. EXPERIMENTAL SETUP In order to be able to drive the bus, the HCS12 s CAN TXD and RXD pins are connected to the CAN High-Speed CAN Transceiver IC MCP2551 (http://ww1.microchip.com/downloads/en/devicedoc/21667 f.pdf). This has already been done on the Dragon-12 board. The RXD is connected to the RXD of the HCS12 which is pin PM0 on the board. The TXD is connected to TXD of the HCS12 which is pin PM1 on the board. The CANH and CANL are the CAN High and CAN Low to drive the bus. The RS pin is hardwired to ground. A 5V supply is connected to the Vcc of the transceiver. For CAN Reception: 1) CAN0RFLG = 0xC3; // Reset Receiver Flags 2) CAN0RIER = 0x01; // Enable Receive Buffer Full Interrupt Figure 4 CAN Transceiver Connections For CAN Transmission: 7) CAN0TFLG: Since the plan is to setup a CAN network of 2 nodes, the CANH and CANL of 2 Dragon12 boards are connected as shown below.

CANH CANL Figure 6 Node#1 showing the value of the DIP Switch Status Figure 5 Setup with 2 Dragon-12 boards Seven Seg Display DIP Switch = 0x8E Board B LCD Display (Varistor value) Figure 7 Setup showing the display and DIP switches Board A Figure 8 Node#2 showing the value which changes with changes in Varistor value I. RESULTS The values sent from each board are correctly displayed on other board.

The below figure shows 0x100 Message on Logic Analyzer. The identifier field, the 8 bytes of data, CRC and other fields are seen. Thus it is seen that CAN is a robust protocol which accurately transmits and receives data using only 2 lines. It will be used for a long time till an even better and cost effective alternative is found. The working of the project can be seen on video at this link: https://www.youtube.com/watch?v=vdnlzp- K8ME&feature=youtu.be REFERENCES Figure 9 Message 0x100 The below figure shows 0x100 message which is sent every 15ms. The glitch seen is introduced by the transceiver. [1] The HCS12-9S12 - An Introduction to Software and Hardware Interfacing 2nd - Huang. [2] Wikipedia (http://en.wikipedia.org/wiki/can_bus) [3] Freescale Documentation CONCLUSIONS HCSCAN12 module provides an efficient and optimized method to send and receive CAN messages. Figure 10Message 0x100 sent every 15ms The below figure shows 0x200 Message on Logic Analyzer. The identifier field, the 8 bytes of data, CRC and other fields are seen. Figure 11 Message 0x200 The below figure shows 0x200 message which is sent every 10ms. The glitch seen is introduced by the transceiver. Figure 12Message 0x200 sent every 10ms