Exercise 02_Red LED 점차 빠르게 깜빡이기
< Software Development Process >
< A Simplified Software Development Flow >
< Requirements for Embedded System Development >
> Hardware schematic: The design of hardware system
- 어떤 hardware components가 사용되었는지
- hardware system이 어떤 특징을 제공하는지
- 어떻게 hardware components가 서로 연결되는지
- features가 어떻게 사용되는지
> Datasheet
- Specifications of each hardware component
- What and how many interfaces a hardware component provide
> Programming manual
- Initialization procedure
: 자동차의 ignition system(점화 시스템)과 같이, HW component의 일부를 초기화하여 기능을 시작한다.
- Memory map
: 컴퓨터 시스템에서 사용되는 주소 공간을 나타내는 방법
: a HW component를 프로그래밍하는데 사용되는 memory addresses
(What a specific bit in the memory map means)
- State machine
: How an event modify internal state(s) of a HW component
< About MSP-EXP432P4111 >
< Initialization code >
> Reset_handler() in startup_msp432p411_ccs.c
: 프로세서가 처음 실행할 때 동작하는 reset event
> SystemInit( );
: system_msp432p4111.c에 있다
: MSP-EXP432P4111의 초기화 단계에 필요한 일을 수행
> _c_int00( )
: C 프로그램을 돌리는데 필요한 단계를 수행
예) BSS initialization
< Watchdog Timer (WDT) >
: microcontroller(MCU) 프로그램이 out of control(제어 불능)인지, 작동이 중지되었는지를 모니터링하는 타이머
*데드락에 빠졌는지 확인한다
: 프로그램을 재시작하지 않는 이상 특정 시간 간격 후에 초기화하는 타이머
: 정상 작동 중에는 정기적으로 watchdog 타이머를 리셋하여 경과 시간이 지나지 않게 해야한다.
오류로 인해 컴퓨터가 watchdog을 재설정하지 못하면 타이머가 경과되고 시간 초과 신호가 생성된다.
time-out 신호의 발생은 컴퓨터의 루프가 정상적으로 동작하고 있지 못함을 나타는 신호이다.
발생 시 이를 대처하기 위해 시스템을 안전한 상태로 두고 정상 작동을 복원(재시작)
< Compilation System >
- The individual C statements는 다른 프로그램에 의해 일련의 low-level machine-language 명령어로 번역된다.
- 유닉스 시스템에서 source file을 object file로 translation하는 과정은 compiler driver에 의해 수행된다.
1. Preprocessing phase (Pre-Processor)
: "#" character로 시작하는 directives에 따라 C program을 수정한다
예) #include <stdio.h>
2. Compilation phase (Compiler)
: Source Program → Assembly language Program(text)
: Assembly language is useful
∵서로 다른 high-level languages에 대해 다른 compilers로 공동의 output language를 제공하기 때문
3. Assembly phase (Assembler)
: Assembly Program(text) → Relocatable Object Programs(binary)
4. Linking phase (Linker)
: Relocatable Object Programs(binary) → Executable Object Program(binary)
: merging을 다루고 executable object file을 생성한다.
< Compilation System - Example >
< Download the Executable Binary (Click “Flash”) >
- 이전에 flash하여 생성된 binary는 삭제되고 새 binary가 flash된다
- 약 100만 번 이상 flash하면(썼다 지웠다 하면) 일부분이 wore-out(마모)될 수 있으므로
새 binary에 대해 단순 쓰기만 했는지, flash까지 해주었는지 검증이 필요하다.
< Volatile Memory vs Non-Volatile Memory >
- Volatile memory (휘발성)
: device에 전원이 들어올 때에만 데이터가 유지되는 메모리
- Non-volatile memory (비휘발성)
: device에 전원이 꺼지더라고 저장된 정보가 유지되는 메모리
< Excercise 02 >
> Exercise Objective
빨간색 LED 가 켜졌다가 꺼지면서 깜빡이도록 설계한다.
처음엔 느리게 깜빡이다가 점차 속도가 빨라지도록 설계하는 것이 이 프로젝트의 목표이다.
> 코드
#include "msp.h"
void main(void)
{
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; //stop watchdog timer
P1 -> DIR |= BIT0; //P1.0을 output으로 설정
P1 -> OUT = BIT0; //P1.0에 Red LED 켜기
int i;
int k=100000;
while(1) {
for(i=0; i<k; i++)
P1 -> OUT = 0;
for(i=0; i<k; i++)
P1 -> OUT = 1;
if(k>5000)
k -= 2500;
}
}
*BIT0: 0번 비트가 1로 설정된 값을 나타내는 매크로 상수( 00000001 )
자료는 이화여자대학교 윤명국 교수님의 임베디드시스템및실험 강의에서 가져온 것입니다.
'Study > 임베디드시스템및실험' 카테고리의 다른 글
[Exercise 03] 두 LED 동시에 깜빡이기 (0) | 2023.10.17 |
---|---|
[Lecture 04] LED (1) | 2023.10.16 |
[Lecture 03] Cortex-m, ARM (0) | 2023.10.15 |
[Lecture 02] 전자 기초, Hardware Organization (0) | 2023.10.15 |
[Lecture 01] Embedded System (0) | 2023.10.15 |