CAN In A Day 2L01I. Renesas Electronics America Inc Renesas Electronics America Inc. All rights reserved.

Similar documents
Implementing Bootloaders on Renesas MCUs

RL78 Project Configuration Tips

Low Power Design. Renesas Electronics America Inc Renesas Electronics America Inc. All rights reserved.

Using Software Building Blocks for Faster Time to Market

Low Power Design Michael Thomas, Applications Engineer

Incorporating a Capacitive Touch Interface into Your Design

LibUSB - Create a Solution Without the Class Struggle

Capacitive Touch Based User Interfaces and Hardware-based Solutions

Embedding Audio into your RX Application

Software Development with an Open Source RTOS

RL78 Ultra Low Power MCU Lab

Secure Firmware Update Lab Session

An Introduction to e 2 studio

Rapid RX600 System Development Using the RPDL and PDG

CC05B RX Project Configuration Tips

RL78 Ultra Low Power MCU Lab

ID 025C: An Introduction to the OSEK Operating System

ID B34L: HMI Development with QNX'S Momentics Toolchain and Connected Automotive Reference QNX CAR

Optimizing RX Performance

ID 024C: Auto Code Generation: The Shortest Distance From Idea to Implementation

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

ID 434L: Incorporating a Capacitive Touch Interface into Your Design

ID 730L: Getting Started with Multimedia Programming on Linux on SH7724

ID 020C: Hardware-in-Loop: System Testing Without the System

Getting Started with Renesas Development Tools

ID 321L: KPIT GNU compiler plug-ins for HEW / KPIT Eclipse IDE

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

Enhance Embedded Systems with Low Cost TFT Solutions

FOR IOT PRODUCT DEVELOPMENT

Types of Interrupts:

A11L: 78K0R Low Power MCU

ID 220L: Hands-on Embedded Ethernet Design with an Open Source TCP/IP Stack

Remote Keyless Entry In a Body Controller Unit Application

BASICS OF THE RENESAS SYNERGY TM

BASICS OF THE RENESAS SYNERGY PLATFORM

ID B30C: IP Video Surveillance Applications

Embedded Wireless Technologies

I Introduction to Real-time Applications By Prawat Nagvajara

How to get realistic C-states latency and residency? Vincent Guittot

Learning Module 9. Managing the Sensor: Embedded Computing. Paul Flikkema. Department of Electrical Engineering Northern Arizona University

Using Virtual EEPROM and Flash API for Renesas MCUs RX600 Series

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

EFM32....the world s most energy friendly microcontrollers

Hello, and welcome to this presentation of the STM32L4 power controller. The STM32L4 s power management functions and all power modes will also be

CHAPTER 11 INTERRUPTS PROGRAMMING

Global GPS NMEA over I²C Software Guide V 1.2

MCU R&D Strategies for the Smart Society

Hardware OS & OS- Application interface

Security in Automotive Applications

ID B33C: Developing Rich Graphical User Interfaces Optimized for Embedded Systems

CAN Protocol Implementation

LONMANAGER NSS-10 MODEL

Design Tradeoffs in Industrial Ethernet Hardware Implementations

CAN Node using HCS12

STM8L and STM32 L1 series. Ultra-low-power platform

TA0139 USER MANUAL ARDUINO 2 WHEEL DRIVE WIRELESS BLUETOOTH ROBOT KIT

vcan API USER GUIDE v1.0 Date : 18th December 2016

Operation manual. HDOM-Profibus-V0. More options please visit;

STM32 Cortex-M3 STM32F STM32L STM32W

ID 411C: Capacitive Touch User Interfaces and Hardwarebased

Embedded Systems and Software

Introduction to Embedded Systems

Microcontroller Technologies for Smart Society

EFM32 Series 0: DMA (ARM PrimeCell µdma PL230)

Using FlexIO to emulate communications and timing peripherals

CSE 120. Overview. July 27, Day 8 Input/Output. Instructor: Neil Rhodes. Hardware. Hardware. Hardware

New Generation of CAN Controllers Optimized for 8-bit MCUs

NXP Unveils Its First ARM Cortex -M4 Based Controller Family

12.1. Unit 12. Exceptions & Interrupts

EEL 4744C: Microprocessor Applications. Lecture 7. Part 2. M68HC12 Interrupt. Dr. Tao Li 1

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

RX Family APPLICATION NOTE. I 2 C Bus Interface (RIIC) Module Using Firmware Integration Technology. Introduction. Target Device.

AN1077 APPLICATION NOTE

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

19: I/O. Mark Handley. Direct Memory Access (DMA)

Course Introduction. Purpose. Objectives. Content. Learning Time

LibUSB: Create a Solution Without the Class Struggle!

Renesas Synergy MCUs Build a Foundation for Groundbreaking Integrated Embedded Platform Development

Embedded Systems and Software. Serial Communication

Interrupt is a process where an external device can get the attention of the microprocessor. Interrupts can be classified into two types:

New STM32 F7 Series. World s 1 st to market, ARM Cortex -M7 based 32-bit MCU

STM32G0 MCU Series Efficiency at its Best

Design and Implementation Interrupt Mechanism

CS 134. Operating Systems. April 8, 2013 Lecture 20. Input/Output. Instructor: Neil Rhodes. Monday, April 7, 14

PCAN-ExpressCard CAN Interface for the ExpressCard Slot. User Manual. Document version ( )

Energy Harvesting Reference Design

Advanced Computer Networks. End Host Optimization

User's Guide

Hello, and welcome to this presentation of the STM32 Random Number Generator. The features of this peripheral, which is widely used to provide random

Emulating Dual SPI Using FlexIO

RF Networking With MSP430 & the ez430-rf2500 Session 2 Miguel Morales, MSP430 Applications 6/5/2008 1

Getting Started With the Stellaris EK-LM4F120XL LaunchPad Workshop. Version 1.05

8086 Interrupts and Interrupt Responses:

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

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

Approximately half the power consumption of earlier Renesas Technology products and multiple functions in a 14-pin package

Wed. Aug 23 Announcements

SR5 Serial Protocol - Issue 1.6

Overview of Embedded Systems in Medical Applications

Transcription:

CAN In A Day 2L01I Renesas Electronics America Inc.

Renesas Technology & Solution Portfolio 2

Microcontroller and Microprocessor Line-up 2010 2012 32-bit 8/16-bit 1200 DMIPS, Superscalar Automotive & Industrial, 65nm 600µA/MHz, 1.5µA standby 500 DMIPS, Low Power 32-Bit High Performance DSP, FPU with High Integration Automotive & Industrial, 90nm 600µA/MHz, 1.5µA standby 165 DMIPS, FPU, DSC Industrial, 90nm 200µA/MHz, 1.6µA deep standby 25 DMIPS, Low Power Industrial & Automotive, 150nm 190µA/MHz, 0.3µA standby 10 DMIPS, Capacitive Touch Wide Industrial Format & LCDs Automotive, 130nm 350µA/MHz, 1µA standby 1200 DMIPS, Performance Automotive, 40nm 500µA/MHz, 35µA deep standby 165 DMIPS, FPU, DSC Industrial, 40nm 200µA/MHz, 0.3µA deep standby Embedded Security, ASSP Industrial, 90nm 1mA/MHz, 100µA standby 44 DMIPS, True Low Power Industrial & Automotive, 130nm 144µA/MHz, 0.2µA standby 3

Connect to the Smart Society with CAN! Smart Society Challenge You don t have time to write and debug a reliable CAN driver You need to get your idea to market SOON Solution Use CAN and the CAN API! The CAN API handles controlling the peripheral The CAN peripheral - Handles ALL the low level details Focus on your application! 4 Agenda

Agenda Where Use CAN!? The CAN Dataframe The CAN Mailbox The CAN API Polling vs. Interrupts Transmit Dataframes Polling vs. Interrupt Receive Dataframes Polling vs. Interrupt Error Handling Lab Application Level Considerations 5

Lab Learn how to Initialize the CAN peripheral with the API Transmit from a CAN mailbox Receive data to a mailbox Use a low cost CAN Monitor to view and send CAN dataframes The CAN API The lab is straightforward Reading Understanding Uncommenting code So don t leave! 6

Where CAN is Best! 4 min. Mainly on-board comm. Poor noise immunity Too expensive http://www.youtube.com/watch?v=x9_myouuaaq&feature=youtu.be 7

CAN Continuously Moving into New Fields Machines (knitting) Agriculture Control Electronics Factory Assembly Lines Medical Systems Railway Electronics Marine Electronics Elevators Building Automation Printing, Copying 8

Lowest Levels Dataframe and Mailbox 9

The Dataframe Standard 11-bit ID Dataframe S O F Identifier Rem Req ID extend Control Data (Bytes) C R C A C K I F S 1 11 1 1 6 0-8 bytes 15 1 3+ Application software only reads/writes CAN ID Data Length Code (in Control Field) Data Field 10

Frame Resides in Mailbox Mailbox A.k.a. Message Box, Buffer, Slot Application <-> Bus point of interaction One mailbox handles one complete dataframe (0-8 bytes) RX has 32 mailboxes/peripheral With two channels, 64 mailboxes to use on one bus More mailboxes SW design easier More SW design flexibility Less runtime reconfiguring 11

Managing a Mailbox Field Transmit Receive Setup mailbox Receive Get message ID DLC Write Write Write - Read Read All app needs to do! Data Write - Read HW takes care of rest Tx mailbox: HW takes care of low level transmit details Rx mailbox: HW captures messages with the set ID Mailboxes can be reconfigured at runtime 12

CAN Firmware & Peripheral Interaction Node MCU Node MCU Node MCU Configure a mailbox to send a frame with ID=5 Configure a mailbox to receive ID=5 Firmware Mailboxes ID=5,Data=123,TX Mailboxes Mailboxes ID=5,Data= 123,RX CAN Peripheral Mask Mask Mask Transceiver Transceiver Transceiver 13

Question Which of these do you need in order to setup a mailbox to transmit? 1. CAN ID 2. Data Length Code 3. Data Field 4. All above Which of these do you need to specify to setup a mailbox to receive? 1. CAN ID 2. Data Length Code 3. Data Field 4. All above 14

Application Level 15

Layers (Where are we?) Let s move up the layers. Optional industrial protocol 16

Dealing with the CAN Registers CAN Initialization START Enter CAN reset/ initialization mode Exit CAN sleep mode CAN reset mode? YES Enable CAN ports Set CAN control register - Loopback mode select bit - Message order select bit - Basic CAN mode select bit - Bus error interrupt enable bit NO can be tedious. Sure would be nice to have Set CAN bit timing and baud rate Set mask register Go to CAN operation mode CAN operation mode? YES END NO The CAN API 17

The CAN API Initialization, Port and Peripheral Control R_CAN_Create (ch_nr); R_CAN_SetBitrate (ch_nr); R_CAN_PortSet (ch_nr, action_type); [action_type = ENABLE, DISABLE] R_CAN_Control (ch_nr, action_type); [action_type = ENTERSLEEP_CANMODE, EXITSLEEP_CANMODE, RESET_CANMODE, HALT_CANMODE, OPERATE_CANMODE, CANPORT_TEST_LISTEN_ONLY, CANPORT_TEST_0_EXT_LOOPBACK, CANPORT_TEST_1_INT_LOOPBACK, CANPORT_RETURN_TO_NORMAL] Send R_CAN_TxSet (ch_nr, mbox_nr, frame_p, frame_type); R_CAN_Tx (ch_nr, mbox_nr); R_CAN_TxCheck (ch_nr, mbox_nr); R_CAN_TxStopMsg (ch_nr, mbox_nr); The CAN API Receive R_CAN_RxSet (ch_nr, mbox_nr, stid, frame_type); R_CAN_RxRead (ch_nr, mbox_nr, frame_p); R_CAN_RxPoll (ch_nr, mbox_nr, frame_p); R_CAN_RxSetMask (ch_nr, sid_mask_value, mask_reg_nr); Error Check R_CAN_CheckErr (ch_nr); 18

Polling vs. Interrupts Polling You only need data at a certain execution path You don t want CAN interrupts interfering some other task Note: Overrun New message discarded Overwrite New message overwrites old Interrupts For processing data as soon as it arrives When messages may not be lost - linked messages To avoid overwrite / overrun 19

Transmitting A Frame struct can_std_data_s { uint16 id; uint8 dlc; uint8 data[8]; }; struct can_std_frame_t my_tx_frame.id = 0x700; my_tx_frame.dlc = 2; my_tx_frame.data[0] = 0x11; my_tx_frame.data[1] = 0x22; my_tx_frame; The CAN API R_CAN_TxSet (0, mbox_nr, &my_tx_frame, DATA_FRAME); The API function Waits for previous frame to finish transmit Clears message control register Disables interrupts for mailbox Sets CAN ID Sets DLC Sets transmit data Transmits Dataframe 20

Transmit Verification Not necessary... unless application must know whether message sent yet Example; message in a sequence CAN peripheral will deliver unless Bus Off Just continuously check for Error Passive/Bus Off Polling #define USE_CAN_POLL 1 (config_r_can_rapi.h) Check if data sent by calling API_status = R_CAN_TxCheck (ch_nr, mbox_nr); If API_OK, message was sent! Transmit interrupt #define USE_CAN_POLL 0 Successful Dataframe transmit triggers ISR CAN0_TXM0_ISR() checks which mailbox sent. Flag the application that data has been sent! 21

Question A CAN mailbox configured with an ID can later be reused to handle other IDs? A. True, a mailbox can be reconfigured at runtime. Can a mailbox be reconfigured from transmit to receive? A. Again, yes! A mailbox can be reconfigured at runtime. 22

Configure Mailbox to Receive R_CAN_RxSet(ch_nr, mbox_nr, stid, frame_type); The CAN API The API Waits for any previous transmission/reception to complete Interrupt disables the mailbox Clears mailbox control register Sets Standard ID for selected mailbox Sets Dataframe/Remote frame Sets receive interrupt enabled unless USE_CAN_POLL defined 23

Polling for Received Data How to receive Dataframe in application At System Setup In config_r_can_rapi.h #define USE_CAN_POLL 1 When polling from app, use R_CAN_RxPoll(ch_nr, mbox_nr, frame_p); If this returns API_OK, mailbox has new message, call R_CAN_RxRead (ch_nr, mbox_nr, frame_p); Copies data to address -> frame_p. 24

Using the Receive Interrupt How to receive Dataframe in application At System Setup In config_r_can_rapi.h #define USE_CAN_POLL 0 When frame arrives with ID set by API the CAN Receive ISR triggers Check which mailbox caused the interrupt with R_CAN_RxPoll (ch_nr, mbox_nr, frame_p); If new frame, call R_CAN_RxRead (ch_nr, mbox_nr, frame_p); which copies the data to frame_p Set a flag to tell the main application that data has been received 25

Lab Setup U A R T J-Link Debug 5V DC Not necessary. CAN only needs 0-3.5 V A to mini-b USB cable To PC for J-Link debug SW3 SW2 SW1 LCD YRDK63N CAN Hi = thick red wire -> pin 1 J8 Ring of LEDs v A to B USB cable To PC for Sys Tec CAN monitor SYSTEC CAN bus monitor v 27

Application Level Considerations 28

Your CAN Application - Keep in Mind No real addresses Messages broadcast to whomever happens to listen! Subdivide ID field for higher level functionality 11-bit ID split into user protocol fields Group priority (critical, info,..) Function ID (temp sensor, motor,..) Device address You CAN use! 29

Error Handling Check node state regularly with uint8_t R_CAN_CheckErr(void) The CAN API Returns STATE_ERROR (Error Active): < 127 CAN transmit and receive errors occurred, OK! STATE_ERROR_PASSIVE: Over 127 errors occurred warn user. STATE_BUSOFF: Node will not transmit until it recovers. Pause application, notify user that node is not working. Reinitialize CAN and reset mailboxes when node recovers to Error Active. 30

Minimum Application Handling of Bus Off Normal application activity Poll if peripheral is in Bus Off Peripheral recovered: Bus Off reached Reinitialize CAN! Application can not send or receive System goes into error mode: Poll if peripheral recovers 31

Questions? 32

Connect to the Smart Society with CAN! Smart Society Challenge You don t have time to write and debug a reliable CAN driver You need to get your idea to market SOON Solution Use CAN and the CAN API! The CAN API handles controlling the peripheral The CAN peripheral - Handles ALL the low level details Focus on your application! Do you agree? 33

Renesas Electronics America Inc.