S32G VNP RDB2 RTD Example

Download as pdf or txt
Download as pdf or txt
You are on page 1of 49

S32G-VNP-RDB2

REAL TIME DRIVER


EXAMPLE ENABLEMENT GUIDE

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

− How to import the UART example into S32DS


− How to configure the clock of UART via S32DS
− How to configure the UART setting via S32DS
− How to debug the UART example with S32 debug probe

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

• Go to desired configuration tool:


− Right click on Project,
− Select S32 Configuration Tool…
− Select Open Clocks

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

UART default configuration:


− - Select correct COM Port
− - Select Baudrate of 9600
− - Select none parity checking
− - Select 1 stop bits
− - Select 8 data bits

PUBLIC 9
HANDS ON UART: UPDATE CODE

Generate code method: 1


1.Click on any configuration tool, like Pins
Then click Update Code (ensure desired
project is selected!)
2.The Update Files window pops up. It shows
the detail update information. Click ok button.
3.The configuration .c and .h file will be
generated at “generate” folder.
3

PUBLIC 10
HANDS ON UART: APPLICATION CODE 1
Open the main.c file in S32DS

MCU clock initiation

In Uart_HLD_S32G_DS_Example Project.
Initialization of pins is writing register directly.

PUBLIC 11
HANDS ON UART: APPLICATION CODE 2

Receive data from user

Echo the received data back

PUBLIC 12
HANDS ON UART: BUILD AND DEBUG 1

Build the target :


− Right click on Project,
− Select Build Project
− Print Build information on Console window
− Uart_HLD_S32G_DS_Example1.elf is generated

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

• Connect the PC and UART1


• Open Tera Term and Set the serial port
• the terminal software will show the below
messages. input “Hello”, UART output “Hello
World”

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

Go to desired configuration tool:


− Right click on Project,
− Select S32 Configuration Tool…
− Select Open Pins
− Configure pins to provide the external clock to Tx, Rx signals

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

Generate code method: 1


1.Click on any configuration tool, like Pins
Then click Update Code (ensure desired
project is selected!)
2.The Update Files widow pops up. It shows the
detail update information. Click ok button.
3.The configuration .c and .h file will be
generated at “generate” folder. 3

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

initialize transmit buffer and Borrow transmit area to load


frame via the function Gmac_Ip_GetTxBuff

PUBLIC 24
HANDS ON ETH: APPLICATION CODE 2

Trigger the transmit frame via Gmac_Ip_SendFrame

Verify frame is transmitted/ received

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

−How to import the CAN example into S32DS


−How to configure the clock of CAN via S32DS
−How to configure the port of CAN via S32DS
−How to modify the CAN loopback
−How to debug the CAN example with S32 debug probe

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.

“CAN_example_CT” project is a FlexCAN HLD driver component LoopBack project.

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

disable Loop Back Mode

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

Generate code method: 1


1.Click on any configuration tool, like Pins
Then click Update Code (ensure desired
project is selected!)
2.The Update Files widow pops up. It shows the
detail update information. Click ok button.
3.The configuration .c and .h file will be
Enable Pins.
generated at “generate” folder. 3

PUBLIC 42
HANDS ON CAN: APPLICATION CODE

Add the Can_SetControllerMode


for CanController_1

Add the Port configuration


and initiation function

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.

void CanIf_TxConfirmation(PduIdType CanTxPduId)


{
CanIf_u8TxConfirmCnt++;
CanIf_bTxFlag = TRUE;
}

void CanIf_RxIndication(const Can_HwType* Mailbox,


const PduInfoType* PduInfoPtr )
{
CanIf_u8RxIndicationCnt++;
CanIf_bRxFlag = TRUE;
}

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.

You might also like