controller area network with flexible data for …...may 2017 canopen slide 1 controller area...

50
Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy, Inc. www.esacademy.com

Upload: others

Post on 19-Mar-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

May 2017

CANopen

Slide 1

Controller Area Network

with Flexible Data for

LPC5461x

presented by

Andy Ayre

Embedded Systems Academy, Inc.

www.esacademy.com

Page 2: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Webinar Contents

LPC family introduction

Introduction to ESA

Differences between CAN and CAN-FD

CAN-FD Protocol Overview

CAN-FD on the LPC5461x

CAN Controller Block Diagram

CAN-FD Applications

CAN-FD Support

CANopen Stack Availability

Software API

API Demonstration

May 2017

CAN-FD

Slide 2

Page 3: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Investing in Innovative & Differentiated Technologiesto Maintain our Global Leadership in the Broad Market

Product Innovation

BroadEcosystem

Quality & LongevityLocal

SupportExtensive

Software & Tools

1 2 3 4 5

Why Developers Select LPC

Microcontrollers

Page 4: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

LPC Microcontroller Portfolio

Performance

Mainstream

Entry Level

Cortex-M0/M0+ Cortex-M3 Cortex-M4F

LPC8008-bit Simplicity

LPC1200Robust & Reliable

LPC1800Performance & Integration

LPC4300High Performance

& Integration

LPC1300Entry Level

LPC54000Power Efficiency

& Integration

LPC4000Mid-Range

Performance & Integration

LPC1700Breadth & Scalability

LPC1500Motion Control

LPC1100Scalable Entry Level

Includes devices

w/ Classic CAN

Includes devices

w/ Classic CAN

And CAN-FD

Page 5: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

INTERFACES

SYSTEM

ANALOG

ADC 12b 12ch 5Msps

MEMORY

COREM

ult

ilaye

r B

us

Mat

rix

ROM

ARM Cortex-M4FUp to 180 MHzIncludes MPU

USARTS/LIN 2.2

(10)

I2C FM+

(10)

DMA

Up to

30ch

GPIO Up to 171TIMERS

SCTimer/PWM

RTC

32-bit Timers (5)

WWDTMulti-Rate Timer

Alarm Timer

Clock Generation UnitFRO 12/48/96 MHz, System PLL

Power ControlSingle Vdd power supply, POR, BOD,

reduced power modes

SPI (10) I2S (2)

CAN/CAN-FD (2)

HS USB (1)

FS USB (1)

USBPLL

Ext. Mem. Ctrl SPIFI

SDIO (SD/MMC)

EEPROM 16 KB

Ethernet

DMIC Subsys

TFT LCD

Temp Sensor

Smart Card (2)

Audio PLL

RAMUp to 200 KB

FLASHUp to 512KB

CPU 180MHz Cortex-M4F

Memory Up to 512 KB Flash, Up to 200 KB RAM

16 KB EEPROM

Interfaces for connectivity & sensors Stereo DMIC subsystem

1x HS USB (H/D) w/ on-chip HS PHY, XTAL-less FS

USB (H/D)

10 SPI, 10 I2C, 10 UART, 2 I2S channels (max 10

channels total)

Graphic LCD with resolutions up to 1024x768

Ethernet with IEEE1722 timestamp

2 x CAN-FD controller

Quad SPI flash interface

External Memory interface (up to 32 bits)

Packages LQFP208 (28 x 28 mm), TFBGA180 (12 x 12 mm)

LQFP100, TFBGA100

Operating Operating voltage: 1.71 to 3.6V

Temperature range: -40 to 105 C

FLEXCOMM

(Choose any 10)

LPC546xx Block Diagram

Page 6: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

LPCXpresso54618 CAN-FD Kit

LPC54618 MCU running at 180MHz

128Mb Micron SDRAM

128Mb Micron quad SPI flash

Built-in CMSIS-DAP/J-link debug probe

Ethernet, DMIC, SD card, USB HS/FS ports

Stereo audio codec

Arduino UNO R3 compatible expansion ports

Shield board with TJA1059 dual transceiver

Supported by MCUXpresso SDK for

MCUXpresso IDE, Keil and IAR tools

Development platform for LPC546xx Series

Page 7: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Embedded Systems Academy, Inc.

Founded 1999

Consulting services

Training services

CANopen stacks, PC development/analysis tools, bootloaders

Participate in CANopen standardization

J1939

Flash Magic

May 2017

CAN-FD

Slide 7

Page 8: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

DIFFERENCES BETWEEN

CAN AND CAN-FD

May 2017

CAN-FD

Slide 8

Page 9: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Differences between CAN and CAN-FD

Invented by Bosch in 2011

Finalized and ISO standardized 2015

• ISO 11898-1:2015

Significantly higher bitrates for data

• Limited by transceivers in practice

More data per frame

• Up to 64 bytes

Up to six times higher throughput

Can mix FD and non-FD CAN controllers

Can mix FD and non-FD frames

Need FD-compliant transceivers above 1Mbps

May 2017

CAN-FD

Slide 9

Page 10: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Differences between CAN and CAN-FD

Remote transmission requests not supported

Bit to indicate transmitter error status

Improved error checking

Bus topology and wiring stays the same

• Same networking costs

May 2017

CAN-FD

Slide 10

Page 11: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD PROTOCOL

OVERVIEW

May 2017

CAN-FD

Slide 11

Page 12: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Protocol Overview

Familiar frame format

May 2017

CAN-FD

Slide 12 Diagrams © CiA

Page 13: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Protocol Overview

Arbitration field 11-bit identifier

May 2017

CAN-FD

Slide 13

Arbitration field 29-bit identifier

Diagrams © CiA

Page 14: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Protocol Overview

CAN-FD Control field

May 2017

CAN-FD

Slide 14 Diagrams © CiA

Page 15: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Protocol Overview

CAN-FD Checksum field

May 2017

CAN-FD

Slide 15 Diagrams © CiA

Page 16: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Protocol Overview

“Classical” and “FD” frame formats

FDF - Uses previously reserved bit to select FD

BRS - bit used to change data bitrate

May 2017

CAN-FD

Slide 16 Diagrams © CiA

Page 17: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Protocol Overview

Scope waveform

May 2017

CAN-FD

Slide 17 Diagrams © CiA

Page 18: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Protocol Overview

May 2017

CAN-FD

Slide 18

11-bit ID 29-bit ID FDF BRS

Non-FD 11-bit ✓

Non-FD 29-bit ✓

FD 11-bit ✓ ✓

FD 11-bit, fast data ✓ ✓ ✓

FD 29-bit ✓ ✓

FD 29-bit, fast data ✓ ✓ ✓

Page 19: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Protocol Overview

Independent sample points

ESI - bit to indicate error status of transmitter

Frame includes encoding of number of stuff bits

May 2017

CAN-FD

Slide 19

Page 20: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD ON THE LPC5461X

May 2017

CAN-FD

Slide 20

Page 21: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD on the LPC5461x

Two CAN controllers

Conforms to ISO11898-1

• Supports CAN-FD ISO mode

• Supports all CAN-FD functionality

Global FD and bit rate switching enable

Flexible RAM configuration

RAM sharing between CAN controllers

• Ideal for bridging applications

May 2017

CAN-FD

Slide 21

Page 22: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD on the LPC5461x

May 2017

CAN-FD

Slide 22

Page 23: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD on the LPC5461xReceive

Two receive FIFOs

• Circular or non-circular

• Configurable fill-level interrupt

• Configurable size

64 dedicated receive buffers

Flexible acceptance filtering

Global simplified acceptance filtering

Timestamping

High priority messages

May 2017

CAN-FD

Slide 23

Page 24: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD on the LPC5461xTransmit

Transmit FIFO/queue

• Configurable size

Up to 32 Transmit buffers

May 2017

CAN-FD

Slide 24

Page 25: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD on the LPC5461xTransmit

Transmit events

• Stored in a FIFO

• Configurable FIFO size

• Timestamps

May 2017

CAN-FD

Slide 25

Page 26: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD on the LPC5461x

Dual interrupts per CAN controller

• Configurable

AUTOSAR support

• Can be used with other higher layer protocols, e.g. CANopen, J1939

Test modes

• Loopback

• Pin monitoring

• Direct pin driving

Restricted operation

• Autobauding

Power down

May 2017

CAN-FD

Slide 26

Page 27: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD on the LPC5461x

Transmitter delay compensation

May 2017

CAN-FD

Slide 27

Page 28: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN CONTROLLER BLOCK

DIAGRAM

May 2017

CAN-FD

Slide 28

Page 29: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

LPC5461x CAN Block Diagram

May 2017

CAN-FD

Slide 29

Page 30: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD APPLICATIONS

May 2017

CAN-FD

Slide 30

Page 31: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Applications

Automotive, Medical

• Improved error detection

Firmware updates

• Faster data transfers, lower overhead

Display data

• Better suitability for transferring periodic blocks of data

Security

Data logging

May 2017

CAN-FD

Slide 31

Page 32: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD SUPPORT

May 2017

CAN-FD

Slide 32

Page 33: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

CAN-FD Support

Embedded Systems Academy, Inc.

• Provides full service support

• CAN and CAN-FD

• NXP forums

• Consulting

CANopen Stack

CANopen development tools

May 2017

CAN-FD

Slide 33

Page 34: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

SOFTWARE API

May 2017

CAN-FD

Slide 34

Page 35: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software API

Based on the FLEXCAN API for Kinetis K60

Example

• Uses ISO CAN-FD, 64 bytes per frame

• Uses 1Mbps nominal, 4Mbps data

• Demonstrates transmit and receive

Setup

• NXP LPC5461x evaluation board

• NXP CAN-FD shield

• PC CAN-FD interface, e.g PEAK PCAN-USB FD

• Regular 120 Ohm terminated cable

May 2017

CAN-FD

Slide 35

Page 36: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APIConfiguration

Board_CAN0_Init()

• Sets up pin multiplexing

CAN_GetDefaultConfig()

• Gets a default configuration by filling in a structure

• 125kbps nominal and data

• 0x2001000 RAM base address

• No RTRs

• FD enabled

CAN_Init()

• Uses a configuration structure to initialize CAN controller

CAN_Enable()

• Enables CAN controller

May 2017

CAN-FD

Slide 36

Page 37: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APIConfiguration

can_config_t

• nominalBaudRate

• dataBaudRate

• baseAddress

• timestampClock_Hz

• rejectStandardRTR / rejectExtendedRTR

• enableLoopBack

• enableNonISOMode

• disableFD

May 2017

CAN-FD

Slide 37

Page 38: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software API

Receive Configuration

CAN_SetRxFifoConfig()

• Sets the size of a receive FIFO and enables the FIFO

• Supports both FIFOs

CAN_SetRxGlobalMask()

• Sets the global receive settings to accept all 11-bit or 29-bit messages into a FIFO

CAN_SetRxIndividualMask()

• Configures which 11-bit messages can be received into a FIFO or a message buffer

• Selection of destination is by using a macro

- FLEXCAN_RX_FIFO0_STD_MASK- FLEXCAN_RX_FIFO1_STD_MASK- FLEXCAN_RX_MB_STD

May 2017

CAN-FD

Slide 38

Page 39: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software API

Receive Configuration

CAN_SetRxExtIndividualMask()

• Configures which 29-bit messages can be received into a FIFO or a message buffer

• Selection of destination is by using a macro

- FLEXCAN_RX_FIFO0_EXT_MASK_LOW / HIGH- FLEXCAN_RX_FIFO1_EXT_MASK_LOW / HIGH- FLEXCAN_RX_MB_EXT_LOW / HIGH

May 2017

CAN-FD

Slide 39

Page 40: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APITransmit configuration

CAN_SetTxMbConfig()

• Enables a transmit message buffer

CAN_TransferCreateHandle()

• Creates a “handle” for a specific CAN controller

• One handle per CAN controller

• Associates a CAN controller with a callback function

May 2017

CAN-FD

Slide 40

Page 41: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APITransmit – Message Buffers

CAN_TransferSendBlocking()

• Transmits a CAN message and waits for it to go out onto the bus

• Uses flexcan_frame_t

- length- type- format- proto- bitratemode- id- dataWord / dataByte

May 2017

CAN-FD

Slide 41

Page 42: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APITransmit – Message Buffers

CAN_TransferSendNonBlocking()

• Transmits a message and returns immediately

• Passed is a handle and the message

• Callback function called on transmission

- handle and status

CAN_TransferAbortSend()

• Aborts send

May 2017

CAN-FD

Slide 42

Page 43: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software API

Transmit – FIFO/Queue

CAN_WriteTxFIFO()

• Puts a message into the FIFO/queue

• Returns immediately

May 2017

CAN-FD

Slide 43

Page 44: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APIReceive

CAN_ReadRxFIFO()

• Polls a FIFO

• Fills in structure if message waiting to be read

CAN_ReadRxMb()

• Polls a message buffer

• Fills in structure if message waiting to be read

May 2017

CAN-FD

Slide 44

Page 45: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APIReceive

CAN_TransferCreateHandle()

• Creates a “handle” for a specific CAN controller

• One handle per CAN controller

• Associates a CAN controller with a callback function

CAN_TransferReceiveNonBlocking()

• Returns immediately

• Passed is a handle and rx structure

- Message structure- Message buffer number

• Callback function called on reception

- handle and status

CAN_TransferAbortReceive()

• Aborts message buffer receive

May 2017

CAN-FD

Slide 45

Page 46: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APIReceive

CAN_TransferReceiveFifoNonBlocking()

• Non-blocking receive for FIFOs

CAN_TransferAbortReceiveFifo()

• Aborts FIFO receive

May 2017

CAN-FD

Slide 46

Page 47: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Software APIMiscellaneous

CAN_DeInit()

CAN_GetBusErrCount()

CAN_GetStatusFlags()

May 2017

CAN-FD

Slide 47

Page 48: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

SOFTWARE API

DEMONSTRATION

May 2017

CAN

Slide 48

Page 49: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Where to get started

LPC range of MCUs at nxp.com/lpc

LPCXpresso54618 board at nxp.com/demoboard/om13094

CAN-FD driver add-ons under Downloads tab

Free tools and software at nxp.com/mcuxpresso

Page 50: Controller Area Network with Flexible Data for …...May 2017 CANopen Slide 1 Controller Area Network with Flexible Data for LPC5461x presented by Andy Ayre Embedded Systems Academy,

Embedded Systems Academy, Inc.

May 2017

CAN

Slide 50

1250 Oakmead Parkway Ste. 210

Sunnyvale, CA 94085

(877) 812-6393

www.esacademy.com

www.CANopenStore.com

Andy [email protected]