S32 SDK
FlexCAN Encrypted

Demo application showing the FlexCAN functionalities

Note
If running the encrypted communication: The encryption uses the first non-volatile user key, which needs to be configured by running the CSEc Key Configuration in the driver examples folder.
Encrypted communication works only for CSEc enabled parts. SIM_SDID indicates whether CSEc is available on your device.
If one of the user keys was loaded using the CSEc Key Configuration, any further full erase of the Flash requires a Challenge-Authentication process. This can be done by running the CSEc Key Configuration example again and setting the ERASE_ALL_KEYS macro to 1.

Application description


The purpose of this demo application is to show you the usage of the FlexCAN module configured to use Flexible Data Rate and the CSEc module from the S32K144 CPU using the S32 SDK API.

  • In the first part, the application will setup the board clocks, pins and other system functions such as SBC if the board uses this module as a CAN transceiver.
  • Then it will configure the FlexCAN module features such as FD, Bitrate and Message buffers
  • The application will wait for frames to be received on the configured message buffer or for an event raised by pressing one of the two buttons which will trigger a frame send to the recipient.
  • The frames are sent in plain text by default, but the encrypted mode can be enabled by holding one of the buttons pressed and pressing the other.

Prerequisites


The run the example you will need to have the following items:

  • 1 S32K144 board
  • 1 Power Adapter 12V
  • 3 Dupont male to male cable
  • 1 Personal Computer
  • 1 Jlink Lite Debugger (optional, users can use Open SDA)

Boards supported


The following boards are supported by this application:

  • S32K144EVB-Q100
  • S32K144-MB

Hardware Wiring


The following connections must be done to for this example application to work:

PIN FUNCTION S32K144EVB-Q100 S32K144-MB
CAN HIGH (*) CAN HIGH - J13.1 CAN HIGH - J60.2
CAN LOW (*) CAN LOW - J13.2 CAN LOW - J60.3
BUTTON 2 (PTC13) BTN1 - wired on the board BTN3 - wired on the board
BUTTON 1 (PTC12) BTN0 - wired on the board BTN2 - wired on the board
RED_LED (PTD15) RGB_RED - wired on the board J12.17 - J11.31
GREEN_LED (PTD16) RGB_GREEN - wired on the board J12.16 - J11.30
GND (GND) J3-11 - Slave GND J6 - Slave GND

(*) Those lines must be modulated using a transceiver, if it is not specified the boards already include the CAN transceiver

How to run


1. Importing the project into the workspace

After opening S32 Design Studio, go to File -> New S32DS Project From... and select flexcan_encrypted. Then click on Finish.
The project should now be copied into you current workspace.

2. Generating the Processor Expert configuration

First go to Project Explorer View in S32 DS and select the current project(flexcan_encrypted). Then go to Project and click on Generate Processor Expert Code
Wait for the code generation to be completed before continuing to the next step.

3. Building the project

Select the configuration to be built FLASH (Debug_FLASH) or RAM (Debug_RAM) by left clicking on the downward arrow corresponding to the build button(. Wait for the build action to be completed before continuing to the next step.

4. Running the project

Go to Run and select Debug Configurations. There will be four debug configurations for this project:

Configuration Name Description
flexcan_encrypted Debug_RAM Jlink Debug the RAM configuration using Segger Jlink debuggers
flexcan_encrypted Debug_FLASH Jlink Debug the FLASH configuration using Segger Jlink debuggers
flexcan_encrypted Debug_RAM PEMicro Debug the RAM configuration using PEMicro debuggers
flexcan_encrypted Debug_FLASH PEMicro Debug the FLASH configuration using PEMicro debuggers


Select the desired debug configuration and click on Launch. Now the perspective will change to the Debug Perspective.
Use the controls to control the program flow.

Note
For more detailed information related to S32 Design Studio usage please consult the available documentation.