Over 10 years we help companies reach their financial and branding goals. Engitech is a values-driven technology agency dedicated.



411 University St, Seattle, USA


+1 -800-456-478-23

Getting Started S32K1

Getting Start with CAN Protocol using Automotive Microcontroller(S32K1xx)


Welcome back to the Gettobyte Automotive Series. In today’s video, we will be exploring the 2-way CAN protocol communication between two NXP Semiconductors S32K144 MCUs using the ElectronicsV2 Development Board. This is a crucial aspect of automotive technology that we will be delving into via DIY project for CAN protocol and getting to know on how to use CAN protocol. Let’s dive in and explore this fascinating topic together.

What is CAN Protocol

CAN stands for Controller Area Network, it is a automotive communication protocol.

Problem Statement

We are going to explore how to use CAN protocol technology in Microcontrollers. We will be doing Handson activity on CAN protocol by doing 2-way CAN protocol communication between ElecronicsV2 development board, which is built on S32K144 Microcontroller.

In S32K144 Microcontroller to use CAN protocol technology, there is a peripheral present in it called as FlexCAN. To Know more in Detail about FlexCAN Module, refer to. We will be using following features of CAN protocol via FlexCAN peripheral present in NXP S32K1xx MCU Microcontrollers:

  1. Standard CAN at 500K BaudRate.
  2. CAN0 Port in Normal Mode.(PTE5 and PTE4)
  3. CAN communication via Message Buffers in polling mode.
  4. Payload size of 8 bytes, with 16 message buffers configured.

Lets get Started

Okay so now let’s get started with it. We Will now at first directly going to do the practical implementation of CAN protocol and then in next blog will dig deep into the CAN API level understanding.

For doing the Practical Implementation of CAN protocol, following 6 steps have to be covered:
  1. Embedded Hardware and Software Tools arrangement: Tool needed.
  2. Embedded Hardware Connection.
  3. Writing/Cloning Embedded Software Project Code.
  4. Generating/Opening the project code and building it.
  5. Flashing the Project code and seeing the expected Output.
  6. Debugging the Project and analyzing its working.

1) Tools needed

Now to do above stated DIY project, we will be needing following Hardware ans Software Tools.

In Hardware Part, we will be needing:

  1. 2* ElecronicsV2 Development Board:
  2. 2* ProBug Debugger: Debugger to program/debug the ElecronicsV2 Board.
  3. 2* ST7789 LCD Screen Module.
  4. Innomaker USB-to-CAN analyzer.
  5. Male Jumper Wires.

In Software Part, we will be needing:

  1. S32 Design Studio IDE: v3.4
  2. S32K1 RTM SDK v4.0.3
  3. Innomaker USB-to-CAN Software

2) Hardware Connections

For doing this DIY project, we have to do certain Hardware connections:

  1. Connection of 2 ElecronicsV2 boards for CAN Communication, over CAN0 port.
  2. Connection of ElecronicsV2 board with ST7789 LCD Screen over SPI pins.

3) Cloning Embedded Software Project Code for CAN Protocol

Now for microcontroller programming on ElecronicsV2. we have made a separate Github repo, where all the demo examples and peripheral codes would be committed with time. Repo is private, those who wanna clone the repo and access it contact us via : Contact us – Get To Byte. We will add interested to our Watch list.

ElecronicsV2 Demo Codes( to access it contact us via: https://gettobyte.com/contact-us/)

Once you get the access for it, you will ElecronicsV2 Repo on Github: 


After Cloning the project, you can see its folder structure in your host Desktop/Laptop.

4) Opening Embedded Software Project Code and building it for CAN Protocol.

Now after you have cloned the project, navigate to Peripheral_Drivers -> CAN -> CAN_ElecronicsV2 and you will see an example project: CAN_ElecronicsV2. This is the our main demo project that we are gonna use and we will be opening it in S32 Design Studio 3.4.

P:S: Make sure in your S32 Design Studio 3.4, S32K1 RTM SDK v4.0.3: Software package is downloaded as it is instructed over here: Getting Started with S32 Design Studio Part 1 – Get To Byte, before opening the CAN_ElecronicsV2 project.

Now open the S32 Design Studio and we have to open the CAN_ElecronicsV2 project into it.  So as to open this project in S32 DS, navigate to file->Open Project from File System. To know how to open the already developed project in S32 DS, refer to this blog: Getting Started with S32 Design Studio Part 1 – Get To Byte.


After opening the project, you can see it open in the project explorer of S32 Design Studio. Drop Down the Src folder and you will see main files of CAN_ElecronicsV2.


In the Project, you can see .mex file: CAN_ElecronicsV2.mex file. This is very important file, as this file opens the code configuration tool for S32K144 Microcontroller. To know more in depth about code configuration tool, checkout this blog: Getting Started with S32 Design Studio Part 2 – Get To Byte. Double Clicking on .mex will open the GUI based window, in which you can see components and sections to configure the peripherals of S32K144 Microcontroller.

In our last blog FlexCAN Peripheral in S32K144, we have learnt the meaning of FlexCAN sections in Code Configuration Tool. Also in the Project, you can see number of files and folders. Don’t worry and don’t get overwhelmed with it. We will cover details of these folders in next blog, for now just move ahead.

Now in This CAN Demo project, their are 4 examples:

  1. CAN_Example1: CAN transmission code via blocking method using ElecronicsV2 at 500K baudrate.
  2. CAN_Example2: CAN transmission & receiving using blocking method example between ElecronicsV2 and PC via innomaker.
  3. CAN_Example3: CAN receiving code via blocking method using ElecronicsV2 at 500K baudrate.
  4. CAN_Example4: CAN Communication Between PC and elecronicsV2(via polling) at 500K baud rate and adding FreeMaster Code with it (only analyzing variables and scope) 

You can see these 4 example by Right clicking on Project and going to Build Configuration:


We are going to use CAN_Example 1 and CAN_Example 3. In CAN Example1: We are transmitting the data continously and in CAN Example3: we are waiting to receive the data at CAN0 port. We have configured the Message ID: 0x800 for both transmitting and receiving nodes.

Now for Building the code, open the CAN_ElecronicsV2 project in 2 different workspaces. In work workspace open the Example 1 and in another workspace open the Example 3.

After that Build both the projects by clicking on the Project name and then going to Project Icon in Toolbar and click on Build the project. Project will start compiling(you can see building process in console view)).

After Building the project as stated in above steps, you would be able to see the executable files of our example projects. Now we have to flash these executables files(.elf) in ElecronicsV2 Development Boards.

Executable Files of CAN Project

5) Flashing the Project code.

Okay so now we have Opened the CAN Demo projects in S32 Design Studio successfully and also compiled corresponding example projects successfully. Now we are gonna flash these examples project into the ElecronicsV2 Boards. 

  1. For doing so, connect the ProBug Debugger with ElecronicsV2 Development Board by connecting JTAG-SWD 10 pin connector Present in ElecronicsV2 with JTAG SWD 10 pin connector present in ProBug Debugger via 10-pin Female to Female connecting wire.
  2. If you are using latest ElecronicsV3 Development Board of S32K144 Microcontroller, it has on-board Jlink Debugger. So no need to connect any wires, just Connect the USB-to Type C cable and you are good to go.

Now for flashing the project into ElecronicsV2. Click on Run-> Run Configurations. A Pop-up window like this will come up and click on GDB Segger J-Link Debugging and then Top icon of New Launch Configuration:


After clicking on New Launch Configuration. The Run Lunch Configuration would automatically be genrated for the Example project which you have selected in Project Explorer. I have here shown for Example3, same way Example1 Run Launch configuration would be generated.


Following things should be take care:

  1. Make sure in main tab, you have browsed the C/C++ application with correct *.elf file. It should be of example project on which you are working, often many a times. Like here we are working on Example3, so CAN_Example3 should be wriiten in path. And CAN_Example1 for example1.
  2. In Debuggers tab, select the device name. Some time Device name is not automatically added. By Device Name we mean MCU name, which is S32K144.
  3. In Debuggers tab, their is column with (USB Serial), adjacent to Connection Type. Write the Serial Number of Jlink Debugger which is connected to PC. As we would be connecting 2 ElecronicsV2 boards to same Desktop, so it means 2 Debuggers would be connected. So as to distinguish between these 2 debuggers during the flashing of elf file, we will configure the USB serial of corresponding Jlink Debuggers with corresponding examples which has to be flashed via them. To know the Serial Number of Jlink Debugger, connect the Jlink Debugger (whether ProBug Debugger or On -Board Debugger) and search for Jlink Commandor, a pop up will come into which you can find serial numbers:
  4. Also change the GDB port of any one configuration from 2331 to 2335. Otherwise their will be conflict in GDB server port, when we start the Run/Debug Configuration.

Here our Example 1 is Transmitting CAN Node and Example 3 is Receiving CAN node.

After you have done all the Run configurations and Hardware Connections as Told in 2nd Section(Hardware Connections). You will start seeing the Output as shown in starting of the video.


6) Debugging the Project code and analyzing the code

Now if you want to Debug the code and do step-by step debugging/analyzing of the code.  All steps are same as done in Step 5. Just instead of Clicking on Run Configuration, we will click on Debug Configurations and similar pop-up and setting will come as we have done in Step 5. 


After that click on Debug and you will see that Debug window for both the Launches.

Now first let the CAN_Example3( which is our receiving code) Run and you will see on its LCD screen CAN receiving related messages will start coming. And also make a breakpoint on line number 82. When CAN will receive the data, it will stop at line no 82.

After that, Run the CAN_Example1( which is our transmitting code) Run and you will see on its LCD screen CAN transmission related messages will start coming. 

And now you will see that when CAN_Example1 node transmitts the Data, CAN_Example3 node will stop at line number 82. And further you step down the CAN Example 3, the transmitted string will be printed on the screen.

To get better understanding and clarity of the Debug configuration, will recommend to watch the video, In which i have explained this thing in a better way.

You can also analyze different variable values and expression values in Debug Mode.



Kunal Gupta

Leave a comment

Stay Updated With Us

Error: Contact form not found.