S32G VNP RDB2 RTD Example
S32G VNP RDB2 RTD Example
S32G VNP RDB2 RTD Example
PUBLIC
NXP, THE NXP LOGO AND NXP SECURE CONNECTIONS FOR A SMARTER W ORLD ARE TRADEMARKS OF NXP B.V.
ALL OTHER PRODUCT OR SERVICE NAMES ARE THE PROPERTY OF THEIR RES PECTIVE OW NERS. © 2021 NXP B.V.
CONTENTS
• Hands on UART Real Time Driver example
• Hands on ETH Real Time Driver example
• Hands on CAN Real Time Driver example
PUBLIC 1
HARDWARE REQUIREMENT AND SOFTWARE INSTALLATION
Hardware Requirement
- S32G-VNP-RDB2
- S32 Debug Probe
- AD/DC power supply
- Serial port cable for UART example
Software Installation
- Install S32DS 3.4 according to S32G-VNP-RDB2 Software Enablement Guide
- Install SW32_RTD_4.4_1.0.0 HF1(RTD) according to S32G-VNP-RDB2 Software Enablement Guide
PUBLIC 2
Hands on UART Example
PUBLIC
NXP, THE NXP LOGO AND NXP SECURE CONNECTIONS FOR A SMARTER W ORLD ARE TRADEMARKS OF NXP B.V.
ALL OTHER PRODUCT OR SERVICE NAMES ARE THE PROPERTY OF THEIR RES PECTIVE OW NERS. © 2021 NXP B.V. 3 PUBLIC 3
HANDS ON UART: OBJECTIVE
PUBLIC 4
HANDS ON UART: IMPORT UART EXAMPLE PROJECT
Open S32DS3.4, go to “File -> New -> S32DS Project From Example”. Select “Uart_HLD_S32G_DS_Example” example,
Then click on “Finish”. The project should now be copied into current workspace.
1
The purpose of “Uart_HLD_S32G_DS_Example” example is a simple application which shows the usage of
UART driver.
PUBLIC 5
HANDS ON UART: CLOCK CONFIGURATION 1
PUBLIC 6
HANDS ON UART: CLOCK CONFIGURATION 2
Open the Peripheral Clock View, Double click the Lin module. The Clocks Diagram will show the power tree. In
Uart_HLD_S32G_DS_Example project. The default clock configuration of UART is 48 MHZ which comes from FIRC directly
PUBLIC 7
HANDS ON UART: UART CONFIGURATION 1
Open the Clocks Diagram:
− Right click on Project,
− Select S32 Configuration Tool…
− Select Peripherals
PUBLIC 8
HANDS ON UART: UART CONFIGURATION 2
The Components shows all drivers which used by this example, the UART_43_LINFLEXD_1 includes
the configuration of UART driver
PUBLIC 9
HANDS ON UART: UPDATE CODE
PUBLIC 10
HANDS ON UART: APPLICATION CODE 1
Open the main.c file in S32DS
In Uart_HLD_S32G_DS_Example Project.
Initialization of pins is writing register directly.
PUBLIC 11
HANDS ON UART: APPLICATION CODE 2
PUBLIC 12
HANDS ON UART: BUILD AND DEBUG 1
PUBLIC 13
HANDS ON UART: BUILD AND DEBUG 2
Go to debug configuration: Debug configuration set:
− Right click on Project, − Click target project ,
− Select the Debug As − Select the target device
− Click Configurations − Select target S32 Debug Probe
PUBLIC 14
HANDS ON UART : DEBUG AND RUN
Click on “Apply”, then click on “Debug”. the perspective will jump to the Debug Perspective, and you can
use the controls to control the program flow.
PUBLIC 15
HANDS ON UART: TEST RESULT
URAT1
PUBLIC 16
Hands on ETH Example
PUBLIC
NXP, THE NXP LOGO AND NXP SECURE CONNECTIONS FOR A SMARTER W ORLD ARE TRADEMARKS OF NXP B.V.
ALL OTHER PRODUCT OR SERVICE NAMES ARE THE PROPERTY OF THEIR RES PECTIVE OW NERS. © 2021 NXP B.V. 17 PUBLIC 17
HANDS ON ETH – OBJECTIVE
−How to import the ETH example into S32DS
−How to configure the clock of ETH via S32DS
−How to configure the port of ETH via S32DS
−How to use the ETH module to transmit/receive ETH frame
−How to debug the ETH example with S32 debug probe
PUBLIC 18
HANDS ON ETH: IMPORT ETH EXAMPLE PROJECT
Open S32 Design Studio, go to “File -> New -> S32DS Project From Example”. Select “Eth_Example_DS_001” example,
then click on “Finish”. The project is copied into current workspace.
This “Gmac_Example_DS_001” example demonstrates the GMAC transmit and receive in internal loopback mode. The
ETH frame is transmitted back directly through GMAC, and the frame will not be transmitted to PHY.
PUBLIC 19
HANDS ON ETH : PORT CONFIGURATION
PUBLIC 20
HANDS ON ETH : CLOCK CONFIGURATION
Open the Peripheral Clock View, Double click the GMAC0 module. The Clocks Diagram shows the power tree of
GMAC module
PUBLIC 21
HANDS ON ETH: ETH CONFIGURATION
Open the peripheral configuration: Select Components to find out GMAC_1 Driver and
• Right click on Project, double click
• Select S32 Configuration Tool…
• Select Peripherals
PUBLIC 22
HANDS ON ETH: UPDATE CODE
PUBLIC 23
HANDS ON ETH: APPLICATION CODE 1
Initialize pins to provide the external clock to Tx, Rx signals via the function Siul2_Port_Ip_Init
Initialize clock to Tx, Rx signals via the function Clock_Ip_Init
Enable controller, initialize Tx and Rx buffer via the function Gmac_Ip_Init
PUBLIC 24
HANDS ON ETH: APPLICATION CODE 2
PUBLIC 25
HANDS ON ETH: BUILD AND DEBUG 1
Build target Project:
− Right click on Project,
− Build Project
− The console print build information
− Eth_Example_DS_001.elf is created
PUBLIC 26
HANDS ON ETH: BUILD AND DEBUG 2
Go to debug configuration: Debug configuration set:
− Right click on Project, − Click target project ,
− Select the Debug As − Select the target device
− Click Configurations − Select target S32 Debug Probe
PUBLIC 27
HANDS ON ETH: DEBUG AND RUN
Click on “Apply”, then click on “Debug”. the perspective will jump to the Debug Perspective, and you can
use the controls to control the program flow.
PUBLIC 28
HANDS ON ETH: TEST RESULT
In this project. The eth frame of Transmit & receive in internal loopback mode. The rxBuffer shows the
received frame.
PUBLIC 29
Hands on CAN Example
PUBLIC
NXP, THE NXP LOGO AND NXP SECURE CONNECTIONS FOR A SMARTER W ORLD ARE TRADEMARKS OF NXP B.V.
ALL OTHER PRODUCT OR SERVICE NAMES ARE THE PROPERTY OF THEIR RES PECTIVE OW NERS. © 2021 NXP B.V. 30 PUBLIC 30
HANDS ON CAN – OBJECTIVE
PUBLIC 31
HANDS ON CAN : IMPORT CAN EXAMPLE PROJECT
Open S32DS3.4, go to “File -> New -> S32DS Project From Example”. Select “CAN_example_CT”
example, then click on “Finish”. The project is copied into current workspace.
PUBLIC 32
HANDS ON CAN: THE PROPOSED DEMO NEED TO MODIFY
The “CAN_example_CT” project only support loopback model. modify this default project configuration to
build transmit/receive CAN frame from FlexCAN_0 to FlexCAN_1
PUBLIC 33
HANDS ON CAN: PORT CONFIGURATION 1
• Go to desired configuration tool:
− Right click on Project,
− Select S32 Configuration Tool…
− Select Open Pins
− Modify the Pins as the schematic of CAN0 and CAN 1
PUBLIC 34
HANDS ON CAN: PORT CONFIGURATION 2
• Add the Port configuration: - Click the plus button
− Right click on Project, - Click the Siul2_Port component
- The Siul2_Port_1 will be added
− Select S32 Configuration Tool…
− Select Open Peripherals
PUBLIC 35
HANDS ON CAN: CLOCK CONFIGURATION 1
Go to desired configuration tool:
− Right click on Project,
− Select S32 Configuration Tool…
− Select Open Clocks
PUBLIC 36
HANDS ON CAN: CLOCK CONFIGURATION 2
Open the Peripheral Clock View, double click the FLEXCAN0_CLK. The Clocks Diagram will show the power tree and
the key node can be re-set. The default clock configuration of CAN is 40 MHZ. the CAN PE clock source comes from
FXOSC
PUBLIC 37
HANDS ON CAN: CAN CONFIGURATION 1
Open the Clocks Diagram:
− Right click on Project,
− Select S32 Configuration Tool…
− Select Peripherals
PUBLIC 38
HANDS ON CAN: CAN CONFIGURATION 2
Configure the Baud rate as 500Kbps for Controller 0
− TimeQuantum (seconds) = Prescaler / CanClockFrequency
− No. of CanTimeQuantas = (1 / CancontrollerBaudRate) / TimeQuantum
− No. of CanTimeQuantas = 1 + CanControllerPropSeg + CanControllerSeg1 + CanControllerSeg2
PUBLIC 39
HANDS ON CAN: CAN CONFIGURATION 3
Open the peripheral configuration view
− add a new CanController for FLEXCAN_1
− Set Hardware Channel as FLEXCAN_1
− Set CAN Rx/TX Processing Type as POLLING
− Set CanCpuClockRef as 40Mhz
− Set Baudrate as 500kbps
Set Baudrate
PUBLIC 40
HANDS ON CAN: CAN CONFIGURATION 4
Modify the CanHardwareObjects Configuration for CanController 0 and CanController 1
Set the CanHardwareObjects_0 reference to CanController 1
Set the CanHardwareObjects_1 reference to CanController 0
PUBLIC 41
HANDS ON ETH: UPDATE CODE
PUBLIC 42
HANDS ON CAN: APPLICATION CODE
PUBLIC 43
HANDS ON CAN: BUILD AND DEBUG 1
Build target Project:
− Right click on Project
− Build Project
− The console print build information
− CAN_example_CT1.elf is created
PUBLIC 44
HANDS ON CAN: BUILD AND DEBUG 2
Go to debug configuration: Debug configuration set:
− Right click on Project, − Click target project ,
− Select the Debug As − Select the target board
− Click Configurations − Select target debugger
PUBLIC 45
HANDS ON CAN: DEBUG AND RUN
Click on “Apply”, then click on “Debug”. the perspective will jump to the Debug Perspective, and you can
use the controls to control the program flow.
PUBLIC 46
HANDS ON CAN: TEST RESULT
Through the modification, the CAN frame transmits from CAN0 to CAN1. the callback function
CanIf_RxIndication capture the received CAN frame.
PUBLIC 47
NXP, THE NXP LOGO AND NXP SECURE CONNECTIONS FOR A SMARTER WORLD ARE TRADEMARKS OF NXP B.V. ALL OTHER PRODUCT OR SERVICE NAMES ARE THE PROPERTY OF THEIR RESPECTIVE OWNERS. © 2021 NXP B.V.