2L01I Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 2L02I CAN In A Day Carl Stenquist, Staff.

Slides:



Advertisements
Similar presentations
Course Introduction Purpose This training course provides an overview of the CAN peripheral in Renesas M16C and R8C microcontrollers that is used to build.
Advertisements

So, you think you need USB On-The-Go?. Agenda Introduction Embedded Host terminology OTG – Electrical – Protocol When to use OTG 2.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L02B Introduction to the RX-Arduino (Lab) Anthony.
The 8051 Microcontroller and Embedded Systems
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Using a Renesas Code Generation Tool for RL78 Devices.
SERIAL BUS COMMUNICATION PROTOCOLS
DCP COMMAND …bringing two-way communications to your DCPs.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. RL78 Ultra Low Power MCU Lab.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Migrating from 8-to-32 bit Processors CC17I Kevin.
ID 413C: Can Touch This: Designing Capacitive-Based Touch Solutions Mark F Rodriguez Senior Engineering 13 October 2010 Version: 1.0 Xaplos Inc.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Instant Connectivity for the “Internet of Things”
ICMP (Internet Control Message Protocol) Computer Networks By: Saeedeh Zahmatkesh spring.
Renesas Electronics America Inc. ID 311L: PIC to R8C Converter David Hedley Staff AE, Applications Engineering 14 Oct 2010 Version: 1.1.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Increase the Dynamic Range and Precision of Digital Filters.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. An Introduction to e 2 studio.
© 2008, Renesas Technology America, Inc. All Rights Reserved The RCAN-ET peripheral and the CAN API SH2 & SH2A MCUs V 1.2 Mar 2010.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Know your Precise Position with RX600 MCU.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Sensorless Vector Control with RL78G14.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID A15C: Application Code Reprogramming Using Different Serial.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID 320L: Rapid RX600 System Development Using the RPDL and.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L13B David Hedley, Applications Engineer Advanced.
Renesas Electronics America Inc. “© 2010 Renesas Electronics America Inc. All rights reserved ID 220L: Hands-on Embedded Ethernet Design with an Open Source.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. 431L: Using a Graphics API to Create User Interface Components—Advanced.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 9L02I Software Development with an Open Source.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. LibUSB - Create a Solution Without the Class Struggle.
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
Scott Baker Will Cross Belinda Frieri March 9 th, 2005 Serial Communication Overview ME4447/6405.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Migrating from CubeSuite+ to Eclipse.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 2L03I RL78 Bluetooth Connectivity Anthony Harris,
Renesas Electronics America Inc. RX USB Peripheral The Renesas RX USB peripheral a.k.a. USBC_597IP_PP Ver
ID A16C: Outfitting Embedded Devices with Low Power Wireless Communications Design considerations for adding wireless communications to low power embedded.
1 The Internet and Networked Multimedia. 2 Layering  Internet protocols are designed to work in layers, with each layer building on the facilities provided.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. e 2 Studio – Getting Started.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Know your Precise Position with RX600 MCU Huangsheng.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Debugging on RX with IAR Embedded Workbench Micael.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. 113C: Migration to the RX600 Made Easy Life in the fast lane.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID630L: Becoming Familiar with Sensorless Vector Control.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose This training course provides an overview of Message Frames.
KeyStone Training Multicore Navigator: Packet DMA (PKTDMA)
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using Virtual EEPROM and Flash API for.
Renesas Technology America, Inc. Flash!. CPU Rewrite CPU-rewrite is a term that refers to an Renesas MCU’s ability to erase/program its own internal Flash.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. QuantiPhi for RH850 and RL78 - The Fastest Path from Idea.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Increase the Dynamic Range and Precision of Digital.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Implementing Bootloaders on Renesas MCUs.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Audio Solutions on the RX MCU Family Mitch Ferguson,
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Advanced Debugging on the RX600.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Advanced E 2 Studio Topics.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: CC05B RX Project Configuration Tips John Breitenbach,
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Low Power Design Michael Thomas, Applications Engineer.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID 230L: Simplify your Networked Application with CAN and.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L08I Migrating from CubeSuite+ to Eclipse Neelima.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L05I Advanced Debugging on the RX600 Fatih Peksenar.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 5L08I Using the Renesas Graphics API to Create.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose:  This course provides an overview of the serial communication.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID 322L:Advanced Debugging on the RX600 Brandon Hussey Applications.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID 421L: R8C Segment-LCD API Lab Bob Proctor Staff Engineer.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID A10L:A Flexible Flash Rewrite Application Brandon Hussey.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: QuantiPhi for RH850 and RL78 - The Fastest Path.
ID 021L: Model Based Control Design and Auto-Code Generation using the R8C Christopher Myers Director of Software Development 12 October 2010 Version:
An Introduction to CAN CAN Basics 2 Renesas Interactive
Wireless and Mobile Networks (ELEC6219) Session 4: Efficiency of a link. Data Link Protocols. Adriana Wilde and Jeff Reeve 22 January 2015.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Overview: Using Hardware.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using Software Building Blocks for Faster.
Introduction Purpose Objective Content Learning Time
David Hedley Staff AE, Applications Engineering 12 Oct 2010
RX Watchdog Timer (WDT)
Ethernet and Token Ring LAN Networks
ID 325L: Getting Started with CubeSuite
Net 323 D: Networks Protocols
Presentation transcript:

2L01I Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 2L02I CAN In A Day Carl Stenquist, Staff AE

© 2012 Renesas Electronics America Inc. All rights reserved.2 Staff Applications Engineer Design of CAN API for R8C, M16C, R32C, SH, RX Manage & support CAN drivers & middleware Development & support USB class driver and sample apps Previous Experience CAN truck electronics, Stoneridge Electronics, Sweden. 6 years designing and supporting CAN firmware applications for Renesas MCUs. MScEE, Chalmers University of Technology, Sweden. Carl Stenquist

© 2012 Renesas Electronics America Inc. All rights reserved.3 Renesas Technology & Solution Portfolio

© 2012 Renesas Electronics America Inc. All rights reserved.4 Microcontroller and Microprocessor Line-up Wide Format LCDs  Industrial & Automotive, 130nm  350µA/MHz, 1µA standby 44 DMIPS, True Low Power Embedded Security, ASSP 165 DMIPS, FPU, DSC 1200 DMIPS, Performance 1200 DMIPS, Superscalar 500 DMIPS, Low Power 165 DMIPS, FPU, DSC 25 DMIPS, Low Power 10 DMIPS, Capacitive Touch  Industrial & Automotive, 150nm  190µA/MHz, 0.3µA standby  Industrial, 90nm  200µA/MHz, 1.6µA deep standby  Automotive & Industrial, 90nm  600µA/MHz, 1.5µA standby  Automotive & Industrial, 65nm  600µA/MHz, 1.5µA standby  Automotive, 40nm  500µA/MHz, 35µA deep standby  Industrial, 40nm  200µA/MHz, 0.3µA deep standby  Industrial, 90nm  1mA/MHz, 100µA standby  Industrial & Automotive, 130nm  144µA/MHz, 0.2µA standby bit 8/16-bit

© 2012 Renesas Electronics America Inc. All rights reserved.5 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! Connect to the Smart Society with CAN! Agenda

© 2012 Renesas Electronics America Inc. All rights reserved.6 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 Agenda

© 2012 Renesas Electronics America Inc. All rights reserved.7 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 lab is straightforward Reading Understanding Uncommenting code… So don’t leave! The CAN API

© 2012 Renesas Electronics America Inc. All rights reserved.8 Where CAN is Best! – 4 min. Mainly on-board comm. Too expensive Poor noise immunity

© 2012 Renesas Electronics America Inc. All rights reserved.9 CAN – Continuously Moving into New Fields Machines (knitting) Machines (knitting) Agriculture Agriculture Control Electronics Control Electronics Factory Assembly Lines Factory Assembly Lines Medical Systems Medical Systems Railway Electronics Railway Electronics Marine Electronics Marine Electronics Elevators Elevators Building Automation Building Automation Printing, Copying Printing, Copying

© 2012 Renesas Electronics America Inc. All rights reserved.10 Lowest Levels Dataframe and Mailbox

© 2012 Renesas Electronics America Inc. All rights reserved.11 The Dataframe “Standard” 11-bit ID Dataframe ID extend 1 Rem Req 1 I F S 3+ Data (Bytes) 0-8 bytes C R C 15 ACK1ACK1 SOF1SOF1 Identifier 11 Control 6 Data (Bytes) 0-8 bytes Identifier 11 Control 6 Application software only reads/writes CAN ID Data Length Code (in Control Field) Data Field

© 2012 Renesas Electronics America Inc. All rights reserved.12 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 Frame Resides in Mailbox

© 2012 Renesas Electronics America Inc. All rights reserved.13 Managing a Mailbox 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 Transmit Write Field ID DLC Data All app needs to do! Receive Setup mailbox Write - - Receive Get message Read

© 2012 Renesas Electronics America Inc. All rights reserved.14 CAN Firmware & Peripheral Interaction CAN Peripheral Firmware Node MCU Mask ID=5,Data=,RXID=5,Data=123,TX Configure a mailbox to receive ID=5 Configure a mailbox to send a frame with ID=5 Mailboxes Transceiver 123…

© 2012 Renesas Electronics America Inc. All rights reserved.15 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 Question

© 2012 Renesas Electronics America Inc. All rights reserved.16 Application Level

© 2012 Renesas Electronics America Inc. All rights reserved.17 Let’s move up the layers. Layers (Where are we?) Optional industrial protocol

© 2012 Renesas Electronics America Inc. All rights reserved.18 Dealing with the CAN Registers… …can be tedious. Sure would be nice to have… CAN Initialization A CAN API! START Enter CAN reset/ initialization mode CAN reset mode? NO 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 Set CAN bit timing and baud rate Set mask register Go to CAN operation mode CAN operation mode? NO END YES Exit CAN sleep mode R_CAN_Create() The CAN API

© 2012 Renesas Electronics America Inc. All rights reserved.19 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); 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); The CAN API

© 2012 Renesas Electronics America Inc. All rights reserved.20 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 Polling vs. Interrupts

© 2012 Renesas Electronics America Inc. All rights reserved.21 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 Transmitting A Frame struct can_std_data_s { uint16 id; uint8 dlc; uint8 data[8]; }; R_CAN_TxSet (0, mbox_nr, &my_tx_frame, DATA_FRAME); my_tx_frame.id = 0x700; my_tx_frame.dlc = 2; my_tx_frame.data[0] = 0x11; my_tx_frame.data[1] = 0x22; struct can_std_frame_t my_tx_frame; The CAN API

© 2012 Renesas Electronics America Inc. All rights reserved.22 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 Transmit Verification #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! 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

© 2012 Renesas Electronics America Inc. All rights reserved.23 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. Question

© 2012 Renesas Electronics America Inc. All rights reserved.24 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 Configure Mailbox to Receive R_CAN_RxSet(ch_nr, mbox_nr, stid, frame_type); The CAN API

© 2012 Renesas Electronics America Inc. All rights reserved.25 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.

© 2012 Renesas Electronics America Inc. All rights reserved.26 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

© 2012 Renesas Electronics America Inc. All rights reserved.27 Messages are broadcast, and then received by all CAN controllers on the bus. 1.No, only to those mailboxes that have a CAN mailbox set up to receive that ID. 2.Yes, since they must do a CRC check, but the message is only copied to a CAN mailbox if there is one set up to receive that ID.  Question 1 is incorrect. 2 is correct since mail are broadcast and received by all CAN controllers on the bus, they all do a CRC check, only then does the peripheral check if any mailbox is configured to receive that ID.

© 2012 Renesas Electronics America Inc. All rights reserved.28 Lab Setup

© 2012 Renesas Electronics America Inc. All rights reserved.29 Application Level Considerations

© 2012 Renesas Electronics America Inc. All rights reserved.30 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 Your CAN Application - Keep in Mind Group priority (critical, info,..) Function ID (temp sensor, motor,..) Device address You CAN use!

© 2012 Renesas Electronics America Inc. All rights reserved.31 Error Handling Check node state regularly with uint8_t R_CAN_CheckErr(void) 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. The CAN API

© 2012 Renesas Electronics America Inc. All rights reserved.32 Minimum Application Handling of Bus Off Bus Off reached Peripheral recovered: Reinitialize CAN! Normal application activity Poll if peripheral is in Bus Off Application can not send or receive System goes into error mode: Poll if peripheral recovers

© 2012 Renesas Electronics America Inc. All rights reserved.33 Questions? Questions?

© 2012 Renesas Electronics America Inc. All rights reserved.34 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? Connect to the Smart Society with CAN!

© 2012 Renesas Electronics America Inc. All rights reserved.35 Please utilize the ‘Guidebook’ application to leave feedback or Ask me for the paper feedback form for you to use… Please Provide Your Feedback…

Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved.