25
http://www.deviceshop.net http://cafe.naver.com/avrstudio 1 1. Introduction 1.1. About this Manual This manual is intended to provide the user with an overview of the board and benefits, complete features specifications, and set up procedures. It contains important safety information as well. 1.2. Feedback and Update to this Manual To help our customers make the most of our products, we are continually making additional and updated resources available on the JK Electronics technical support website (http://cafe.naver.com/avrstudio ). These include manuals, application notes, programming examples, and updated software and hardware. Check in periodically to see what’s new! When we are prioritizing work on these updated resources, feedback from customers is the number one influence, If you have questions, comments, or concerns about your product or project, please no hesitate to contact us at mailto:[email protected] . 1.3. Limited Warranty JK Electronics warrants this product to be free of defects in material and workmanship for a period of six month from date of buy. During this warranty period JK Electronics will repair or replace the defective unit in accordance with the following process: This limited warranty does not cover damages resulting from lighting or other power surges, misuse, abuse, abnormal conditions of operation, or attempts to alter or modify the function of the product. This warranty is limited to the repair or replacement of the defective unit .In no event shall JK Electronics be liable or responsible for any loss or damages, including but not limited to any lost profits, incidental or consequential damages, loss of business, or anticipatory profits arising from the use or inability to use this products. Repairs make after the expiration of the warranty period are subject to a repair charge and the cost of return shipping. Please contact JK Electronics to arrange for any repair service and to obtain repair charge information. 4. License of this manual 이 매뉴얼의 JK전자에 의해서 번역, 수정, 작성 되었고 소유권 또한 JK전자의 것입니다. 소유권자의 허가를 받지 않고 무단으로 수정, 삭제하거나 배포 할 수 없습니다.

avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

Embed Size (px)

Citation preview

Page 1: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

1

1. Introduction

1.1. About this Manual

This manual is intended to provide the user with an overview of the board and

benefits, complete features specifications, and set up procedures. It contains

important safety information as well.

1.2. Feedback and Update to this Manual

To help our customers make the most of our products, we are continually making

additional and updated resources available on the JK Electronics technical support

website (http://cafe.naver.com/avrstudio).

These include manuals, application notes, programming examples, and updated software

and hardware. Check in periodically to see what’s new!

When we are prioritizing work on these updated resources, feedback from customers is

the number one influence, If you have questions, comments, or concerns about your

product or project, please no hesitate to contact us at mailto:[email protected].

1.3. Limited Warranty

JK Electronics warrants this product to be free of defects in material and

workmanship for a period of six month from date of buy. During this warranty period

JK Electronics will repair or replace the defective unit in accordance with the

following process:

This limited warranty does not cover damages resulting from lighting or other power

surges, misuse, abuse, abnormal conditions of operation, or attempts to alter or

modify the function of the product.

This warranty is limited to the repair or replacement of the defective unit .In no

event shall JK Electronics be liable or responsible for any loss or damages,

including but not limited to any lost profits, incidental or consequential damages,

loss of business, or anticipatory profits arising from the use or inability to use

this products.

Repairs make after the expiration of the warranty period are subject to a repair

charge and the cost of return shipping. Please contact JK Electronics to arrange for

any repair service and to obtain repair charge information.

4. License of this manual

이 매뉴얼의 JK전자에 의해서 번역, 수정, 작성 되었고 소유권 또한 JK전자의 것입니다.

소유권자의 허가를 받지 않고 무단으로 수정, 삭제하거나 배포 할 수 없습니다.

Page 2: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

2

2010 Copyright by JK Electronics.

Page 3: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

3

1. 왜 Cortex 인가? ................................................................. 4

2. 개발환경 구축 ................................................................... 6

2.1 컴파일러 ................................................................... 6

2.2 플래시 프로그램 ............................................................ 6

2.2.1 시리얼 플래시 다운로드를 이용하는 방법 ............................... 6

2.2.2 JTAG 다운로드 장비를 이용하는 방법 .................................. 10

2.3 Keil MDK 에서 H-JTAG USB 를 이용한 디버깅.................................. 18

2.4 IAR Workbench(EWARM) 에서 H-JTAG USB 를 이용한 디버깅...................... 21

Page 4: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

4

STM32 개발환경 및 플래시 다운로드

Cortex-M3 코어 중에서도 ST Microelectronics 사의 제품인 STM32 MCU에 대해서 간단하게

리뷰를 해보고 그 중에서도 STM32F103VCT6를 사용하는 개발보드에 대해서 간단한 예제를

작성해 보면서 쉽게 접근 할 수 있도록 하는 것이 주요 목표이고 가능 하다면 STM32

MP3개발보드에 장착되어 있는 VS1003B MP3 Codec을 이용해서 SD메모리 카드에 저장된

MP3파일을 플레이 해보는 것을 목표로 하도록 하겠습니다.

1. 왜 Cortex 인가?

지난 6~7년간 일반적인 목적의 마이크로 컨트롤러를 위한 CPU로 ARM7, ARM9을 채택해

왔으며 오늘날 수 많은(약 240개) ARM-Based의 마이크로 컨트롤러가 존재합니다. 이러한

시점에서 ST Microelectronics 는 ARM Cortex-M3 microcontroller core를 기반으로 한 첫

번째 제품으로 STM32 라는 MCU 제품 군을 발표 하였습니다.

이 새로운 MCU는 성능과 비용뿐만이 아니라 저전력의 hard real-time controller 입니다.

ARM Cortex family는 광범위한 기술적인 요구사항을 충족하기 위하여 기존의 ARM CPU들과는

다른 새로운 standard architecture를 제공 하는데, Cortex family 에는 A, R, M type의

3가지 Profile이 있습니다.

Cortex-A Series

Applications processors for complex OS and user applications.

Supports the ARM, Thumb and Thumb-2 instruction sets.

Cortex-R Series

Real-time systems profile.

Supports the ARM, Thumb, and Thumb-2 instruction sets.

Cortex-M Series

Microcontroller profile optimized for cost-sensitive applications.

Supports Thumb-2 instruction set only.

STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와 low power

consumption 를 위하여 디자인 되었으며 이것은 충분히 8, 16비트 마이크로 컨트롤러와도

가격적인 면에서 경쟁력이 있습니다.

ARM7, ARM9은 특별이 exception 과 interrupt handling 에서 훌륭한 성능을 가지고 있는데,

그것은 각각의 제조사에서 그들만의 특별한 솔루션을 가지고 디자인을 했기 때문입니다.

Cortex-M3 는 Interrupt system, Systick timer, Debug system and memory map 등의

Page 5: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

5

Standard microcontroller가 가지고 있는 기능을 제공 하며 4Gbyte 의 address 영역은 code,

SRAM, Peripherals and system peripherals 등의 영역으로 나누어져 있습니다. ARM7과

다르게 Cortex-M3는 Harvard architecture 구조이고 multiple bus를 가지고 있어서 동시에

작업이 가능하기 때문에 ARM7 보다 성능 면에서 우수 합니다..

이전의 ARM architectures 와 달리 Cortex family 는 unaligned data 를 access할 수

있어서 internal SRAM 을 효율적으로 사용 할 수 있고 또한 bit banding 이라는 방법으로

1Mbyte 영역 안에서 Bit를 Set하고 Clear할 수 있어서 peripheral registers 와 SRAM

memory 에 위치한 Flag 등을 효과적으로 set 하고 clear 할 수 있습니다. STM32의 주요

핵심 부분은 Cortex-M3 processor 이고 Cortex-M3 processor 는 32bit CPU로서 nested

interrupt unit과 debug system, standard memory layout을 가지고 있습니다.

Cortex-M3 core의 중요한 요소의 하나로 Nested Vector Interrupt Controller (NVIC)가

있습니다. NVIC는 Cortex core에 기반을 둔 모든 마이크로 컨트롤러들에게 표준적인

interrupt와 exception handling 구조를 제공합니다. NVIC는 주변 기기들로부터 240개가

넘는 인터럽트 벡터를 제공 하고, 그 인터럽트는 각각 우선순위를 정할 수 있습니다.

인터럽트가 발생 후 인터럽트 서비스루틴(함수) 의 시작 코드에 도달하는데 까지 걸리는

시간은 12사이클의 소요 됩니다. 이러한 기능은 CPU 안의 microcode 에 의해서 수행 되어

지는 automatic stack handling 부분에 의해서 가능합니다. 연속적인 인터럽트 서비스의

경우 NVIC는 "tail chaining" 기법으로 6사이클 안에 인터럽트 서비스를 제공 합니다.

인터럽트 적층(stacking)단계에서 high priority interrupt는 low priority interrupt를

추가적인 CPU Cycle 소모 없이 선점 할 수 있습니다. 또한 인터럽트 구조는 Cortex-M3

Core의 저전력 모드에서도 잘 구성 되어 있는데 이것은 자동으로 저 전력 모드로 진입하고

인터럽트를 이용해서 low power mode(저 전력 모드)에서 벗어 나게 할 수 있는 구조를

가능하게 합니다.

Cortex core는 24비트 auto reload 타이머를 가지고 있어서 RTOS kernel을 위한

periodic interrupt(Sys clock)를 제공 합니다. ARM7과 ARM9코어는 32-bit ARM

instruction과 16-bit Thumb instruction의 2개의 Instruction set를 제공하는데, Cortex

family는 성능적으로 유리한 32-bit instructions과 코드 집적도가 높은 Thumb 16-bit

instruction가 혼용된 Thumb-2 instruction set를 제공 합니다.

Page 6: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

6

2. 개발환경 구축

2.1 컴파일러

Cortex-M3 개발을 위한 컴파일러로 여러 가지가 있지만 주로 많이 사용하는

컴파일러로EWARM IAR Workbench와 KEIL MDK를 주로 많이 사용하는 것 같습니다.

여기 에서는 KEIL MDK 3.80 컴파일러를 사용하도록 하겠습니다.

2.2 플래시 프로그램

개발보드에 컴파일한 바이너리 파일을 다운로드 하기 위해서 2가지 방법이 있습니다.

첫째로 STM32에서 기본으로 제공하는 시리얼 플래시 다운로드를 이용하는 방법이 있고

둘째로 JTAG 다운로드 장비를 이용하는 방법이 있습니다. 2가지 모두에 대해서 살펴보도록

하겠습니다.

2.2.1 시리얼 플래시 다운로드를 이용하는 방법

시리얼 인터페이스를 이용하면 별도의 비용부담 없이 PC의 COM포트를 이용해서 타겟보드에

컴파일한 바이너리 이미지를 다운로드 할 수 있습니다. 하지만 비용이 들지 않는 반면에

디버깅을 할 수는 없습니다.

시리얼을 이용해서 다운로드를 하려면 우선 STM32F103VET6를 내부 시스템 부팅모드로 설정

해야 합니다. 시스템 부팅 모드에 대해서는 차후에 자세히 알아보도록 하고 우선은

개발보드의 점퍼를 설정(JP1의 점퍼를 제거 합니다.)하고 바로 실습을 해보도록 하겠습니다.

(1) STM32 Flash Loader프로그램 실행

참고로 STM32 Flash Loader프로그램과 메뉴을은 아래 경로에서 다운받으실 수 있습니다.

http://www.st.com/stonline/products/support/micro/files/um0551.zip

http://www.st.com/stonline/products/literature/um/13916.pdf

Page 7: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

7

장치관리자에서 시리얼 포트번호를 확인하고 “Next”진행.

Page 8: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

8

“Next” 다음 진행

“Next” 다음 진행

Page 9: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

9

“Download to device”를 선택하고 hex파일을 선택 합니다. “Next” 다음 진행

타겟 보드에 플래시 다운로드 완료

Page 10: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

10

2.2.2 JTAG 다운로드 장비를 이용하는 방법

STM32를 지원하는 장비에는 H-JTAG, J-Link, ULINK, ST-Link 등 여러 가지가 있습니다.

시리얼을 이용해서 바이너리 이미지를 다운로드 할 수는 있지만 개발 중에 디버깅을 할 수

없다는 단점이 있습니다. 물론 UART나 LED등을 이용해서 기본적인 내용은 확인 할 수는

있지만 그리 효율이 좋지는 못합니다. 그래서 고가의 비용을 투자해서 JTAG장비를 이용하는

것입니다. 여기서는 H-JTAG 장비를 이용하는 방법에 대해서 설명 하도록 하겠습니다.

(1) H-JTAG 소프트웨어 다운로드하고 설치

http://cafe.naver.com/avrstudio/H-JTAG V1.0 Release.zip

에서 소프트웨어를 다운로드 하고 설치 합니다.

(2) H-JTAG 드라이버 설치

H-JTAG 장비를 PC와 연결하면 USB 드라이버를 설치 해야 합니다.

Page 11: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

11

Page 12: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

12

Page 13: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

13

(3) H-JTAG 을 개발보드의 JTAG 포트에 연결하고 H-JTAG 서버 실행

H-JTAG 서버가 실행 되면서 아래와 같이 Cortex-M3를 Detect 하게 됩니다.

Page 14: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

14

Cortex-M3 용 “TAP Configuration” 설정

“STM32F” 버튼 클릭

Page 15: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

15

(4) 바이너리(Hex) 파일을 개발보드에 다운로드

H-Flasher 실행

H-Flasher 설정, 아래 그림들에서는 STM32F103VC를 선택 하였지만 Flash를 여기

개발보드에서는 STM32F103VET6을 선택 합니다.

Page 16: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

16

Page 17: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

17

“Program” 버튼 클릭

Page 18: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

18

2.3 Keil MDK 에서 H-JTAG USB 를 이용한 디버깅

- Toolconf 를 실행 시켜서 Keil MDK의 디버거 설정에 H-JTAG RDI 인터페이스 추가

- “Config” 버튼 클릭

- MDK 디버거 설정을 위해서 “Option for target” 아이콘 클릭

Page 19: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

19

디버거를 “H-JTAG CORTEX-M3” 로 설정 한 후 “Setting” 버튼을 누르면

아래와 같이 H-JTAG About 창이 나와야 합니다.

- Flash loader 설정

Page 20: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

20

- H-Flasher 설정(디버깅을 위해서는 “Auto Flash Download” 로 설정)

- 디버깅 시작

H-Flasher 에서 “Auto Flash Download”로 설정 하면 디버깅 시작 시 자동으로

H-Flasher 가 호출 되어서 타겟에 이미지를 다운로드 하게 됩니다.

여기서 한가지 주의 할 점은 Keil MDK환경에서는 디버깅 시작 시에만 이미지를 다운로

드 할 수 있고 이미지만 다운로드 하기 위해서는 H-Flasher에서 직접 실행 해야만 합

니다.

Page 21: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

21

2.4 IAR Workbench(EWARM) 에서 H-JTAG USB 를 이용한 디버깅

IAR에서 디버깅을 하기위해서는 5.4 버전 이상을 사용해야 합니다.

- RDI 인터페이스 Configure

- Target 설정

Page 22: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

22

Page 23: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

23

- Debugger 설정을 “RDI” 를 선택

- RDI 디라이버를 “H-JTAG.dll” 로 설정

Page 24: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

24

- RDI -Configure

Page 25: avrstudio - 전자부품/전자공구/개발보드 전문쇼핑몰 - 툴파츠 · 2010-10-19 · STM32 는 Cortex-M3 profile 을 기반으로 특별히 high system performance 와

http://www.deviceshop.net http://cafe.naver.com/avrstudio

25

- 디버깅 시작