MCU Information
MCU: TC234LP
- CPU core: max frequency = 200MHz
- Program Flash(code): size = 2Mbyte
Data Flash(EEPROM):size = 128Kbyte
cache: instruction = 8kbyte, data = 4line read buffer
Board: SAK-TC234LP-32F200N AC - Infineon product identifier: SA
SAK-TC234LP-32F200N AC
- Temperature range: K(-40 ~ +125 °C)
- TriCore: TC
- Architecture: 2
- Series: Package Class = 3 (100-PIN)
- Core Architecture: L(Single Core)
- Feature Package: P = Standard feature
- Memory Size: Flash size code = 32(2MB)
- Memory Type: F
- Frequency: 200MHz (160MHz까지 사용)
기자재
- Wire harness
- CAN
- IGN
- ECU (SCU Gen6)
- Dap
- Can Case
- Vector VN1610
- Trace32
개발환경
- Aurix Development Studio
- Trace32
- EB Tresos for MCAL
: AUROSAR 기반 SW 개발 도구- 기본 소프트웨어(BSW) 모듈과 런타임 환경(RTE)을 설정하고, 이를 기반으로 코드를 생성
- AUTOSAR 표준에 따라 ECU 소프트웨어를 모듈화하고, 설정(configuration)과 매핑(mapping)
- Vector Driver (? 안한거같음)
- Toolsus (?)
Compiling & Linking
빌드 = compling + linking
compling
- source code(A.cpp) -> object code(A.o)
- 사람의 언어 -> 기계어
linking
- object code(A.o) -> executable(foo.exe, foo.hex)
- hex: bianry file
- (임베디드) 메모리 배치
GTM; Generic Timer Module
40M oscillator
GTM driver is responsible for initializing the clock, the Input/output multiplexer registers and providing GTM
interface to ICU, PWM and GPT modules. The initialization of GTM driver must be called before executing
ICU / PWM / GPT functionality or any other module which is dependent on GTM. The GTM driver is also
responsible for calling the respective interrupt service routines as per the configuration done by the user.
Besides, GTM driver provides basic interfaces for all the sub-modules that are available in GTM peripheral.
TOM; Timer Output Module
- TOM은 GTM의 서브모듈
- PWM 신호 생성
- 동기화 기능
- 다양한 클럭 소스
- 인터럽트 지원
- dead time 삽입
GTM의 Clock은 80MHz
실습) 1ms에 한 번씩 호출되는 함수
Mcu -> McuModuleConfiguration_0 -> GtmConfiguration_0 -> Tom_0 -> TomChannel_0 -> TomChannelClockSelect
values: (clock selected by ____)
- GTM_FIXED_CLOCK_0: FXCLKSEL
- GTM_FIXED_CLOCK_1: FXCLKSEL / 2^4
- GTM_FIXED_CLOCK_2: FXCLKSEL / 2^8
- GTM_FIXED_CLOCK_3: FXCLKSEL / 2^12
- GTM_FIXED_CLOCK_4: FXCLKSEL / 2^16
#include "Gpt.h"
static uint32 timeEcuAlive1ms = 0u; static uint32 systemTimerLatest;
static uint32 systemTimerPrevious = 0u; static uint32 timerDiffUs = 0u;
#define GptChannelId_0 0u
void GptNotification_1ms(void) { // 하드웨어가 호출 = 인터럽트
systemTimerLatest = *((uint32 *)(0xF0000010u)); /* 80MHz */ timeEcuAlive1ms++;
timerDiffUs = (systemTimerLatest - systemTimerPrevious) / 80;
systemTimerPrevious = systemTimerLatest;
}
void ScuMain(void) {
Gpt_EnableNotification((Gpt_ChannelType) GptChannelId_0);
Gpt_StartTimer(GptChannelId_0, 5000u ); /* 80MHz/16/5000tick = 1000hz = 1ms */
while(1);
}
위 코드를 기반으로 TomChannelClockSelect를 GTM_FIXED_CLOCK_ 0~4로 바꾸어가며 Gpt_StartTimer의 두번째 인자를 수정하여 GptNotification_1ms함수가 1ms마다 호출되도록 설정해보자.
GTM_FIXED_CLOCK_ 0 -> 80,000u (overflow)
GTM_FIXED_CLOCK_ 2 -> 312.5 (not integer)
GTM_FIXED_CLOCK_ 3 -> 19.53 (not integer)
GTM_FIXED_CLOCK_ 4 -> 1.221 (not integer)
Timer Module
- CCU6; Capture Compare Unit6
- GPT12; General Purpose Timer Unit
- 타이머 및 카운터 기능
- 인터럽트 생성
- 펄스 폭 측정
- 펄스 생성
- 증분 인터페이스 모드
GPT; General Purpose Timer Unit
The GPT Driver uses the GTM peripheral of the AURIX platform. The Driver can be configured with multiple
channels. Each channel consists of a timer cell for which Clock and Timeout value has to be configured. The
following operations can be performed on each channel.
- Start / Stop the timer
- Avail wakeup functionality
- Enable / Disable notification
- One Shot or Continuous mode of operation
STM; System Timer Module
gpt에서 만든 타이머 모듈이 잘 동작하는지 확인
AUTOSAR(AUTomotive Open System ARchitecture)
: 자동차 소프트웨어의 표준화된 아키텍처

목적.
- 개발 편의성: SW 구조를 표준화 및 규칙 제정 → 개발 및 검증 과정 효율화
- 재사용성: 개발 SW 공통 부문 일괄 사용 → 유사 SW 반복 개발 억제
- 모듈화: 타 모빌리티 적용 가능한 모듈화 → 노동력 및 비용 절감
Architecture.
- Application Layer(ASW)
- Runtime Environment(RTE)
- Basic Software(BSW)
- Hardware Layer
1. ASW(Application Layer)
; 차량의 기능을 구현하는 Software Components (SWCs)로 구성
- SWC는 특정 차량 기능(예: 엔진 제어, 브레이크 제어, 센서 데이터 처리 등)을 담당하며, 표준화된 인터페이스를 통해 다른 SWC 또는 하드웨어와 통신
- SWC는 하드웨어에 독립적으로 설계되며, 재사용성과 이식성이 높음
2. RTE(Runtime Environment)
; 응용 계층과 기본 소프트웨어(BSW) 간의 미들웨어 역할. 모든 컴포넌트는 RTE를 통해 통신한다.
between Component: autosar interface
between BSW: autosar standarized API
between MCAL: standarized API
- SWC 간 또는 SWC와 BSW 간의 통신을 관리하며, 이를 통해 소프트웨어 모듈이 하드웨어에 의존하지 않고 동작할 수 있도록 함.
- RTE는 ECU별로 생성되며, 각 ECU에서 실행되는 SWC들의 연결을 정의
3. BSW(Basic Software)
; ECU의 하드웨어를 제어하고 응용 계층에 필요한 서비스를 제공
- Services Layer
- 진단 서비스(Diagnostic), 메모리 관리(Memory Management), 통신 서비스(Communication Services) 등을 제공
- 예: NVM(Non-Volatile Memory Manager), DCM(Diagnostic Communication Manager)
- ECU Abstraction Layer
- 특정 하드웨어에 종속적인 기능을 추상화하여 상위 계층이 하드웨어에 독립적으로 동작할 수 있도록 함
- 예: ADC 드라이버, PWM 드라이버
- MicroController Abstraction Layer(MCAL)
- 마이크로컨트롤러와 직접 상호작용하는 드라이버를 포함
- 예: CAN 드라이버, SPI 드라이버, GPT 드라이버
- Complex Drivers
- 기본 소프트웨어와 응용 계층 간의 특수한 요구사항을 처리하기 위한 드라이버
4. Hardware Layer
- 실제 ECU 하드웨어(마이크로컨트롤러, 센서, 액추에이터 등)를 포함
- MCAL을 통해 상위 계층과 연결
ADC; Analog-to-Digital Converter
Step.
- 아날로그 신호
- Sampling
- Quantization
- Encoding
12bit Conversion (0~4095)
- Resolution: analog 신호를 정밀하게 digital로 나타낼 수 있는 정도
- Sampling Frequency: ADC의 Clock frequency에 의해 결정
- Conversion time: Analog -> Digital 변환에 소요되는 시간
- Reference Voltage(V_AREF): AD변환기의 최대 범위값 = Full scale 전압
ignition
- 0이 아닌 1~2인 이유? pull up, pull down 저항
ADC Resolution 설정
Port
Port -> PortConfigSet_0 -> PortContainer_41 -> PortPin
IgnitionVoltage는 PORT_41_PIN_9, PortPinId = 665
665 = 0010 1001 | 1101
41 | 9
실습) Battery ADC를 추가하여 현재 Battery 전압 측정
BAT_MON_A/D: AN23/P41.11 G1CH11
Ref
TC21x-TC22x-TC23x User Manual V1.1.pdf
'IVS > MCAL 제어프로그래밍' 카테고리의 다른 글
ADC, DIO, FLS, FEE, SPI (0) | 2025.02.11 |
---|