This document shows the step-by-step process to create a simple blinking LED application for the S32R45 family using the S32 RTD AUTOSAR drivers. This example used for the S32R45 EVB, connected via ethernet connection through S32 Debugger.
Preparation
Setup the software tools
Install S32 Design Studio for S32 Platform
Install the S32R45 development package and the S32R45 RTD AUTOSAR 4.4. Both of these are required for the S32 Configuration Tools. image.png
Launch S32 Design Studio for S32 Platform
Procedure
New S32DS Project image.png OR image.png
Provide a name for the project, for example 'Blinking_LED_RTD_With_AUTOSAR'. The name must be entered with no space characters.
Expand Family S32R45, Select S32R45 Cortex-M7 image.png
Click Next
Click '…' button next to SDKs DanielBarbu_0-1718877870253.png
Check box next to PlatformSDK_S32RXX_4_0_0_S32R45_M7_0. (or whichever latest SDK for the S32R45 is installed). Click OK image.png
And also, uncheck the other cores Cortex_M7_1 , Cortex_M7_2. DanielBarbu_1-1718878251771.png
Click Finish. Wait for project generation wizard to complete, then expand the project within the Project Explorer view to show the contents. image.png
To control the LED on the board, some configuration needs to be performed within the Pins Tool. There are several ways to do this. One simple way by double-click on the MEX file. image.png
Select the overview tab and disable Pins tool. Make sure to overview tab windows shows settings shown as below. Here, we are disabling pin tools and using MCAL driver from peripheral tools for using AUTOSAR drivers. image.png
Now from Overview menu, select peripheral tools and double click to open it. image.png
In the driver sections, “Siul2_Port_1 driver” is the non-AUTOSAR version driver and so it must be replaced. Right click on ‘Siul2_Port_1’ and remove it. Keep osif_1 driver as it is. image.png
Click on the ‘+’ next to the MCAL box. image.png
Click on the ‘+’ next to the MCAL box again, and Locate and then select the ‘Dio’ component from the list and click OK. image.png
Click on the ‘+’ next to the MCAL box again, and Locate and then select the ‘Mcu’ component from the list and click OK. image.png
Click on the ‘+’ next to the MCAL box again, and Locate and then select the ‘Port’ component from the list and click OK. image.png Now components tab should show like below : image.png
Now we required to configure the different MCAL drivers that we added. Starting with Dio configuration, open the Dio configuration.
Now, open the ‘DioConfig’ tab, and Edit Dio Port id to 3 as shown below: image.png
Now, in “Dio Configuration” window only, Select “+” sign adjacent to DioChannel. image.png
Then Edit Name to “Digital_Output_LED” and Dio Channel Id to ‘5’ instead of ‘0’. image.png From the schematic for S32GR45 EVB, checking for user LED from the schematic, channel 5 is connected to user LED signal, so we use channel 5 signal line to the chip for the user LED. So, we select the singal line for Dio channel Id 5 for the user LED connected on the S32R45 EVB.
Now Select Port tab for Port configuration.
And open the Port Configuration tab, and from that open “PortConfigSet” tab. Change the PortPin Mscr to ‘53’ and slew rate to ‘SRE_208MHZ_1_8V_166MHZ_3_3V’ and, PortPin Direction to PORT_PIN_INOUT as shown below: image.png
Now, at the bottom you will find the “UnTouchedPortPin ’’ . Click on “+’’ and add PortPins. image.png
Now add port pins 0, 1, 2, 3 as per below configuration image.png image.png image.png image.png
Now configure MCU component. Select Mcu component in MCAL, and then open the Mcu configuration.
In Mcu configuration click on MCUModuleConfiguration and then select “McuModesettingConf” from the dropdown menu as shown below. image.png
From McuModeSettingConf, select McuPartitionConfiguration tab. Then open the “McuPartition0Config” tab.
And under the McuCore0Configuration or “McuCoreClockEnable” select checkbox and for “McuCoreResetEnable” uncheck the checkbox.
Similarly, And under the McuCore1Configuration for “McuCoreClockEnable” select checkbox and for “McuCoreResetEnable” uncheck the checkbox.
Similarly, And under the McuCore2Configuration for “McuCoreClockEnable” select checkbox and for “McuCoreResetEnable” uncheck the checkbox. After modification it should be as shown below: image.png
Now open the “McuPartition1Config” tab.
for " Partition1 Clock Enable" select checkmark to true and for " Partition1 Clock Reset Enable" uncheck the checkmark
for " CA53 CORE 0 cluster0 Core Clock Enable" select checkmark to true and for " Cortex-A53 Core 0 cluster 0 Clock Reset Enable" uncheck the checkmark
In the McuCore1Configuration, and for " Cortex-A53 Core 1 cluster 0 Clock Reset Enable" uncheck the checkmark
In the McuCore2Configuration, for " Cortex-A53 CORE 0 cluster 1 Core Clock Enable" select checkmark to true and for " Cortex-A53 CORE 0 cluster 1 Clock Reset Enable" uncheck the checkmark
In the McuCore3Configuration, for " Cortex-A53 CORE 0 cluster 1 Clock Reset Enable" uncheck the checkmark After modification it should be as shown below: image.png
Now open the “McuPartition2Config” tab.
for " Partition2 Clock Enable" select checkmark to true and for " Partition2 Clock Reset Enable" uncheck the checkmark image.png
Now open the “McuPartition3Config” tab.
for " Partition3 Clock Enable" select checkmark to true and for " Partition3 Clock Reset Enable" uncheck the checkmark image.png
Now the device configurations are complete and the RTD configuration code can be generated. Click ‘Update Code’ from the menu bar. image.png
To control the output pin which was just configured, some application code will need to be written. Return to the ‘C/C++’ perspective. image.png
If not already open, in the project window click the ‘>’ next to the ‘src’ folder to show the contents, then double click ‘main.c’ file to open it. This is where the application code will be added. image.png
Before anything else is done, Initialize the clock tree and apply PLL as system clock, Apply a mode configuration, Initialize all pins using the Port driver by adding – editing code before write code here comment in main function.
/* Initialize the Mcu driver */ Mcu_Init(&Mcu_Config_BOARD_InitPeripherals); /* Initialize the clock tree and apply PLL as system clock */ Mcu_InitClock(McuClockSettingConfig_0); /* Apply a mode configuration */ Mcu_SetMode(McuModeSettingConf_0); /* Initialize all pins using the Port driver */ Port_Init(NULL_PTR); image.png
Now replace the logic of for loop as shown below code section in the main function, which will enable the LED blinking for 10 times:
You also need to declare and initialize the loop variable uint8 i = 0U; . Then replace the code as below after write your code comment: /*Logic for blinking LED 10 times*/ while (i++ < 10) { /* Get input level of channels */ Dio_WriteChannel(DioConf_DioChannel_Digital_Output_LED, STD_HIGH); TestDelay(3000000); Dio_WriteChannel(DioConf_DioChannel_Digital_Output_LED, STD_LOW); TestDelay(3000000); } image.png
Before the 'main' function, add a delay function as follows:
void TestDelay(uint32 delay); void TestDelay(uint32 delay) { static volatile uint32 DelayTimer = 0; while(DelayTimer<delay) { DelayTimer++; } DelayTimer=0; } image.png
Update the includes lines at the top of the main.c file to include the headers for the drivers used in the application: Add #include "Mcu.h" #include "Port.h" #include "Dio.h" image.png
Build 'Blinking_LED_RTD_AUTOSAR'. Select the project name in 'C/C++ Projects' view and then press 'Build'. image.png
After the build completes, check that there are no errors. image.png
Open Debug Configurations and select 'Blinking_LED_RTD_with_AUTOSAR_Debug_RAM'. Make sure to select the configuration which matches the build type performed, otherwise it may report an error if the build output doesn’t exist.
And make selection as shown in screenshot below. You need to select the ethernet connection for S32 debugger and provide its IP address image.png
Click Debug
To see the LED blink, click ‘Resume' image.png
This code as it will blink the LED 10 times, you can make changes in for loop condition to blink it infinitely.
記事全体を表示