AUTOSAR IO 실습#
| IO | 포트 번호 |
|---|---|
| PWM(LED Blue) | PTA31 |
| ADC(Pot) | PTA11 |
| SW05 | PTB26 |
| LED_Green | PTA30 |
0. 목차#
- Project 생성
- MCAL Configuration
- IoHwAb Configuration
- VFB level
- RTE level
- C coding
- ECU Mapping
- ECU Extract
- ECU Configuration
- Generate & Build
1. Project 생성#
-
File→Import→General→Existing Projects into Workspace→Next선택

-
Browse..→ Base Project 선택 →Copy projects into workspace체크 →Finish클릭
Copy projects into workspace는 원본 프로젝트 보존 목적 위함.
2. MCAL Configuration#
Configuration->Ecu->Mcal->Ecud_Port.arml->Port더블클릭- 다음 아래의
Container->PortContainer_A->Pin으로 안에 담겨 있는 핀 확인
- 이후 실습에서 스크롤시 세부 설정을 본인도 모르게 스크롤 할 수 있기에 다음 영역(파란 박스 안)에서 스크롤 또는 직접 사이드바 컨트롤 권장

PTA31을 더블클릭- Initial Mode :
PORT_ALT1_FUNC_MODE - Mode :
EMIOS_1_EMIOS_1_CH_14_H_OUT선택 - >Ok클릭
PTA11더블클릭- Direction :
PORT_PIN_IN - Initial Mode :
PORT_ANALOG_INPUT_MODE
Mcal->Ecud_PWM.arxml->Pwm더블클릭 ->Channel로 이동
Configuration->Ecu->Mcal->Ecud_PWM.arxml->Pwm더블클릭 ->Channel클릭
- 우측 상단의 + 버튼 클릭하여 Channel을 생성.
- Short Name :
PwmChannel_PTA31 - Id :
1 - Class :
PWM_FIXED_PERIOD - Period Default :
8191, Dutycycle Default :0
- 이후
Hw Channel을 설정해야함. - 필요한
Hw Channel생성을 위해 이동.

Emios클릭.PwmEmios_0->Channels->PwmEmiosChannels_0- 우측 상단의
+버튼으로 채널을 생성.
- Short Name :
PwmEmiosChannels_CH14 - Emios Ch Id :
CH_14 - Emios Ch Mode :
EMIOS_PWM_IP_MODE_OPWMB - Emios Ch Counter Bus :
EMIOS_PWM_IP_BUS_BCDE
- 다음은 Bus Ref를 설정해야 하지만 필요한 Bus Ref가 없기에 생성해주어야 함.

Mcal->Ecud_Mcl.arxml->Mcl더블클릭.Emios Common으로 이동.
EmiosCommon_1->Emios Mcl Master Bus->+버튼 클릭.- Short Name :
EmiosMclMasterBus_1_CH8, Number :EMIOS_CH_8 - Mode Type :
MCB_UP_COUNTER, Emios Mcl Default Period :8191 - Prescaler :
DIV_12
Pwm->Emios-> PwmEmiosChannels_CH14의 Bus Ref를 생성한EmiosMasterBus_1_CH08로 설정.
-
Channel->Hw Channel,Mcu Clock Reference설정.
-
Hw Channel :
PwmEmiosChannels_CH14

- Mcu Clock :
CORE_CLK

3. IoHwAb Configuration#
Mcal->Ecud_IoHwAb.arxml->IoHwAb더블클릭 ->All Contents클릭
IoHwAbAnalogInputDirect->Logical- 기존에 있던
IoHwAbAnalogInputDirectLogical_Test2의 이름을 다음과 같이IoHwAbAnalogInputDirectLogical_Pot로 변경.
IoHwAbDigitalDirect클릭- 아래와 같이
+버튼 두번 클릭(2개의 Logical을 생성) - Short Name :
IoHwAb…_LED_Green,IoHwAb…_SW05
- LED_Green, SW05의
Port Pin Ch Ref를 설정 - LED_Green :
PTA30, SW05 :PTB26
IoHwAbPwm클릭 ->+버튼 클릭- Short Name :
IoHwAb…_LED_Blue - Hw Pwm Ch Ref :
PwmChannel_PTA31
- 생성한 I/O를 확인하기 위해
Harmonize & generat를 해주어야함. Configure ECU and Generate Code->Generate ECU Configuraton을 클릭.
Next->Rte선택 ->Next->Rte: Generate SwInstance configuration체크 ->Finish클릭
- 좌측 상단의
망치아이콘의 화살표 클릭 ->Generate All클릭 - Generate는 오류가 나오게 되는데 무시해도 무관.
- Generate 완료 후 ->
Configure ECU and Generate Code->Service and I/O클릭 ->Pot,SW05,LED_Green,LED_Blue가 생성되었는지 확인
- 사진과 같이 만든
IO들을 확인할 수 있음.
4. VFB level#
SWC 생성 : SWC_IOTest#
Configuration->System->Swcd_App->New->AUTOSAR File- File name :
App_Rte.arxml -
ARPackage :
App_Rte
-
App_Rte[ARPackage]->New->Application Sw Component Type클릭 - Short Name :
SWC_IOTest -
Supports Multiple Instantiation :
false
-
하단 탭의
Ports클릭 -> 상단 Ports 옆의+클릭 ->Client Server Interface->Client클릭
- 앞의 Client 생성을 총
4번진행함. (+버튼을 4번 눌러서) 아래 그림과 같이IoHwAb_If_DigDir2개,IoHwAb_If_Pwm,IoHwAb_If_AnalnDir를 생성.
- 1번째
IoHwAb_If_DigDir Port클릭 - Short Name :
R_SW05 - Operations :
ReadDirect,Enable Required Com Specs체크

- 2번째
IoHwAb_If_DigDir Port클릭 - Short Name :
R_LED_Green - Operations :
WriteDirect,Enable Required Com Specs체크
IoHwAb_If_AnalnDir Port클릭- Short Name :
R_Pot - Operations :
ReadDirect,Enable Required Com Specs체크

IoHwAb_If_Pwm Port클릭- Short Name :
R_LED_Blue - Operations :
SetDutyCycle,Enable Required Com Specs체크

5. RTE level#
Runnable 설정 : SWC_IOTest#
- 하단 탭의
Runnables클릭 ->+클릭 - Short Name :
RE_IOTest - Symbol :
IOTest_func
RTE Event->Add->Timing Event->OK클릭

- 생성된 Timing Event 더블클릭 -> Period :
100 msec

Operation / Mode / Trigger Access->Add클릭
- Sychronous Server Call Point(SSCP)
4개선택 ->OK클릭 R_LED_Blue.SetDutyCycle&R_LED_Green.WriteDirect&R_PotReadDirect&R_SW05.ReadDirect
6. C coding#
Static_Code->Reference_Code->src폴더 위에서 우클릭 ->New->File
- File name :
SWC_IOTest.c Finish클릭
- C 파일 작성

7. ECU Mapping#
Configuration->System->Composition->RootComposition.arxml->CSWC_RootComposition->Components and Ports클릭+버튼 클릭 ->SWC_IOTest선택 ->OK클릭
8. ECU Extract#
- 상단의
Auto-Wiz→System Configuration&ECU Extract→ECU Software Components Mapping클릭.
- 우측 하단의
OK를 누른 후 추가하고자 하는 SWC와 Connector가 적용되는지 확인한 후Apply클릭.
9. ECU Configuration#
Configure ECU and Generate Code->Generate ECU Configuration클릭
Next->Rte선택 ->Next->Rte: Generate SwInstance configuration체크 ->Finish->OK클릭
- Task Mapping을 위해 상단에
Rte event to Task Mapping클릭
Sw Component Instance->SwcInstance_SWC_IOTest선택 -> Mapping 할 Task로OsTask_ASW_FG1_100ms선택TE_RE_IOTest선택 ->Add
Configure ECU and Generate Code->Servise and I/O클릭- 생성한 Pot, SW05, LED_Green, LED_Blue 를 Mapping 하는 과정

P_IoHwAb…_Pot선택 -> Automatic Connection 우측에+클릭Respect Naming Rule해제 -> 이름 일치하는 것 선택 ->OK- 같은 방식으로 SW05, LED_Green, LED_Blue에 대해 진행

10. Generate & Build#
Build→Scons.arxml→SCons더블클릭 후-
하단의
All Contents→RTSW→Generation→Module
-
Rte폴더 찾기 -
오른쪽 창에서 Input Files List 우측의
Add를 클릭

-
'App_Rte'(이전에 생성한 AUTOSAR file이름) 입력 →
Add→OK클릭
-
좌측 상단 망치의 화살표 클릭 →
Build