레이블이 Embedded System인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Embedded System인 게시물을 표시합니다. 모든 게시물 표시

2018년 2월 26일 월요일

Silicon Lab Download Warning message

Silicon Laboratories 에서 build 된 hex 파일을 다운로드 할 때 Warning message

Warning! An attempt was made to modify address 2200 which is restricted!
Continue download?

말 그대로 수정이 금지된 메모리 주소인 2200 을 수정하려고 한다는 이미이며

실제 사용 가능하지 않는 메모리 영역에 쓰려고 할 때 이 문제가 발생 하였다.

구체적으로는 어떤 상황이었나면
1. C8051F582(64k flash) 에서 사용하던 코드를 C8051F547(8k flash) 에서 사용하려고 해서 위 Warning이 떴고 실제 Code영역의 크기가 10k 를 넘었다.
2. 프로그램의 버전을 Linker 의 옵션으로 주었고 "CODE(?CO?VER(0x7FF6))" 이 때 사용하는 영역인 0x7FF6 이 사용 가능한 메모리 크기를 넘어 위 메시지가 떴다.


2017년 5월 14일 일요일

(E, K)Practical Skills You'll Want to Acquire (당신이 얻고싶은 실질적인 기술들) - So, You Wanna Be an Embedded Engineer[Book]


Embedded Engineer 가 되기 위해서 좋은 책들을 검색해 보았는데, 가장 실질적인 조언을 준다고 생각되는 책(So, You Wanna Be an Embedded Engineer)을 찾았고 그 중 마음에 드는 부분을 번역 해 보았습니다.

한국에서 출간되지 않아 영문책을 구매했기 때문에 전체 내용을 제대로 봤다고 생각되지 않지만.. 아래 내용 Practical Skills You'll Want to Acquire (당신이 얻고싶은 실질적인 기술들) 은 심플하면서 이해가 잘 됩니다.


---

Regardless of how far you eventually intend to specialize, there is a small core of baseline skills that will benefit you greatly in any sector of embedded engineering. Some of these skills are taught explicitly in college, some of them are mentioned peripherally but not examined in any great detail, and the remainder are acquired and honed exclusively through practical experience. 
당신이 전문가가 될지 고민하는것과 상관 없이, 임베디드 엔지니어링의 어느 분야를 공부할 것인지에 상관없이 기본이면서도 가장 중요한 부분이 있습니다. 일부분은 대학교에서 명시적으로 알려주기도 하고, 다른 일부분은 대략 주제는 알게되지만 자세하게 이야기 되지 않습니다, 그리고 나머지는 실질적인 경험으로만 단련될 수 있습니다.

I hope the fact that you're reading this book — and presumably somebody paid to buy it — helps to demonstrate that one of the most important skills you can acquire is to learn the lost art of effective reading and writing in the apparently dead language known as English. Most engineers will probably not author full-length books, but any good engineer will write many thousands of words of technical documents in their careers, including the following: 
저는 당신이 이 책을 읽음으로서 — 아마 돈을 내고 샀을 텐데 — 영어로 배우고 쓴다는 것이 중요하다는 것을 배울 수 있었으면 합니다.(의역) 많은 엔지니어들이 책을 쓰지는 않지만 실질적으로 많은 기술에 대한 문서를 작성합니다. 아래 내용들을 포함하여,

• Product specifications, explaining to marketing and the people who write your product manuals exactly what the product will do 
• 제품 설명서, 제품을 쓸 사람에게 이 제품이 어떻게 동작할 것이라는 것을 명확하게 설명

• Protocol specifications, explaining to other engineers how to talk to your product 
• 통신 규약  설명서, 다른 엔지니어에게 제품과 이야기를 나눌 수 있는지 설명

• White papers, describing to other engineers what you've been working on and useful discoveries you've made 
• 논문, 다른 엔지니어들에게 당신이 무엇을 했고 어떠한 유용한 발견을을 했는지 자세하게 설명

• Patent disclosures 
• 특허 공유

• Instructions to subordinates 
• 같이 일하는 사람들(특히 경험이 없는)에게 지시

• Articles for technical journals (Being published in this way can substantially improve your visibility within an organization — think raises and promotions.) 
• 기술 저널에 글 쓰기(이런곳에 글이 실린다는 건 소속된 회사에서 상당한 존재감을 나타낼 수 있음 — 유명해지거나 승진 등)

• Debugging information, communicating with vendors, quality assurance 
technicians and engineering colleagues to solve complex problems 
• 디버깅 정보, 협력사와 논의 하거나, QA부서 인원 그리고 같은 일을 하는 엔지니어들과 복잡한 문제를 푸는 것)

• Justifications (dare I say it) for taking a specific course of action (When things get out of control and the recriminations start to fly, the one with the best paper trail usually wins.)
• 어떤 일을 해야함을 타당한 이유를 들며 설명할 수 있는 것


Most engineering students — in fact, I can generalize wildly and say most science students — regard language skills as a mere waste of time, required by an idiotic college bureaucracy. Unfortunately for these students, it has been my experience — very rarely contradicted — that engineers who can write intelligible and concise documents are precisely the same engineers whose specifications are complete and easy to understand, whose code is well-structured and simple to read, and who have little difficulty communicating effectively with co-workers. 
엔지니어 공부를 하는 학생들은 — 일반적으로 이야기해서 과학을 하는 학생들은 — 언어 공부는 시간낭비라고 생각한다, 관료적인 것이라고 생각합니다. 불행하게도 그런 학생들에게 이야기 하고 싶은 것은, 내 경험을 미루어 보아 — 대부분은 — 이해하기 쉽고, 간결하게 문서를 작성하고 코드가 잘 구조화된 사람들은 동료들과 소통하는데 덜 어려움을 겪습니다.


You'll note that the BSEE breakdown I gave in Section 2.1 only shows six credits of English. This is more or less representative of the average BSEE degree; you can add a little more writing and speaking experience in the liberal arts electives, but no matter how you wiggle your course schedule, a bachelor's degree in engineering is only going to give you the barest possible taste of formally taught language skills.
제 2.1 절에서 언급 한 BSEE 내역은 영어관련 6 학점 만 보여줍니다. 이것은 BSEE의 평균적인 정도를 나타내는 것입니다. 당신은 교양 선택 과목에서 약간의 쓰기와 말하기의 경험을 추가 할 수 있지만 코스의 일정을 어떻게 바꾸어도 공학 학사는 정식적인 언어 능력의 일부만을 경험할 수 있습니다.

You need to practice this. Voracious reading — not just technical books, but fiction and nonfiction by good authors — is essential; reserve time for it in your week (hints: the bath is a great place to relax and read, and Project Gutenberg has numerous free electronic texts you can download to your PDA and read anywhere) . Practice writing wherever you can; before I was ever published, I honed my skills largely in banter — technical and otherwise — on Usenet and, previously, Fidonet. Good language skills can float a competent engineer significantly above their colleagues.
 당신은 더욱 열심히 책을 읽어야 합니다. — 단순히 기술 책이 아니라 좋은 작가의 소설과 논픽션 — 필수적입니다. 한 주마다 그것을 위한 시간을 마련 하십시오 (힌트 : 목욕시간은 읽을 수있는 완벽한 시간입니다 그리고, Project Gutenberg는 많은 책을 PDA에 다운로드할 수 있게 해 주었습니다. ). 시간 있을 때마다 쓰세요. 내가 첫 책을 출판하기 전에, 기술적으로도 그렇지 않아도 Usenet 및 이전 Fidonet에서 나의 능력을 크게 손질했습니다. 뛰어난 언어 능력은 유능한 엔지니어를 동료들과 선명하게 구별지을 수 있게 해줍니다.

Another essential skill set on which you will not touch significantly in formal education is PCB layout and an understanding of DFM (design for manufacturing) concepts. Both of these are specialties in their own right, but from the perspective of the embedded engineer, they're closely related and can be learned at the same time. Although a design engineer in a company of even modest size probably won't spend any significant time working on layouts, there's a great deal of practical value in understanding at least the basics of what is involved in the processes of designing, laying out, and populating (stuffing) PCBs.
정규 교육에서 배우기 힘든 또 하나의 필수 기술은 PCB 레이아웃 및 DFM (제조를위한 설계) 개념의 이해입니다. 모두 임베디드 엔지니어의 전문 분야이며, 임베디드 엔지니어의 관점에서 보면, 그들은 밀접하게 관련되어 있으며, 동시에 배울 수 있습니다. 아마 적당한 크기의 회사의 설계 엔지니어는 아마 레이아웃 작업에 많은 시간을 할애하지 않지만, 적어도, 디자인, 레이아웃 및 프로세스의 프로세스에 관련되는 기초를 이해하는 데에서 PCB를 채우기 (포장 포함)

I'm not counting people for whom English is a second language in this statement. Wherever I write "English" in this section, you can substitute "the engineer's native language." It's language skill, not specifically English skill, that I'm talking about. However, if only because the majority of scientific and technical publications are in English, it would be prudent to study this language if you don't speak it natively.
저는 영어가 제 2 언어 인 사람을 말하고 싶은것은 아니지만, 이 섹션에서는 '영어'라고 쓴 경우, "엔지니어 모국어 '를 의미한다고 할 수 있습니다. 내가 말하고있는 영어 실력이 아니라 언어 능력입니다. 그러나 과학 기술 잡지의 대부분이 영어로 쓰여져 있는 사실을 생각해 보면 영어를 공부해야 하는것이 당연합니다.

A pre-Internet worldwide network of bulletin board systems; my system was ZWSBBS, 3:634/396. 
Fidonet still exists (though greatly shrunken since my days there) and is connected to the Internet at various points — see <http://www.fidonet.org/> for more information.
인터넷 전의 세계적인 네트워크는 BBS(bulletin board systems) 이었습니다. 저의 경우 ZWSBBS, 3:634/396를 사용 했습니다.
Fidonet은 여전히 존재하며 (많이 그 크기가 줄었지만) 다양한 경로로 인터넷과도 연결되어 있습니다. . 자세한 내용은 <http://www.fidonet.org/>를 참조하십시오.

If you work at a large company, you'll have opportunities to talk to the manufacturing engineers and PCB layout artists and glean a lot of useful wisdom; you should seize these opportunities when available. You don't necessarily need to annoy people with incessant questions; merely listening carefully at design reviews will greatly improve your understanding of the issues. There's a very large body of succulent information tidbits that seem intuitively obvious once you hear them, but which you might never think of yourself;
대기업에서 일하는 경우, 제조 엔지니어와 PCB 레이아웃 아티스트와 이야기를하고 많은 유익한 지혜를 모으는 기회가 있습니다. 이 기회를 잘 활용해야 합니다. 끊임없이 질문하면서 괴롭히라는 것은 아닙니다. 설계 검토 회의 시에 신중하게 듣는 것만으로 중요한 부분에 대한 이해가 크게 향상됩니다. 듣기만 해도 직관적으로 이해되는 다량의 정보들이지만 혼자 일했다면 절대 얻지 못할 것입니다.

for example, the need to keep ceramic surface-mount capacitors away from the edges of PCBs to avoid cracking them during depanelization; ensuring that you leave sufficient clearance around a surface-mounted microcontroller to allow use of a test clip; understanding how components drift or self- align on their pads when they go through the infrared reflow oven; and so on.
예를 들어, PCB를 자를 때(depanelization) 세라믹 표면 실장 커패시터를 PCB의 가장자리에서 멀리 떨어지게 유지해야 커패시터가 부서지는(cracking) 되는 것을 막을 수 있습니다. 테스트 클립을 사용(연결)할 수 있도록 표면 장착형 마이크로 컨트롤러 주변에 충분한 여유 공간을 확보하십시오. 적외선 reflow 오븐을 통과 할 때 패드에서 부품이 어떻게 이동 및  자체 정렬되는지 이해 등등

You'll also need a lot of practical software debugging experience. A good starting point for this is simply your college courses — if you work at the computer science and other programming-related course work with sufficient assiduity, you'll have a reasonable start on the methodology of software debugging by the time you graduate. However, one issue for which school will leave you almost completely unprepared is how to jump in at the deep end and start maintaining someone else's large code project.
실용적인 소프트웨어 디버깅 경험이 많이 필요할 것입니다. 이 과정을 시작하기에 좋은 출발점은 단순히 대학 과정입니다. 컴퓨터 과학 및 기타 프로그래밍 관련 과정을 충분히 조화롭게 공부하면 졸업 할 때까지 소프트웨어 디버깅 방법론을 합리적으로 시작할 수 있습니다. 그러나 학교에서 거의 준비가 안되는 문제 중 하나는 다른 사람의 대규모 코드 프로젝트의 심층적 인 상황에 뛰어 들어 유지보수를 해보는 것입니다.

It is practically guaranteed that your first job (and every subsequent job, for that matter) is going to involve maintaining some legacy code. You can be very lucky and find code that is accurately documented and well-commented, or you can encounter code (as I have) that contains no comments at all and is structured in such a complex and bizarre fashion that adding or removing a single comment line can cause the compiler to abort with an internal error. The most useful learning technique I have found for this is to take an open-source project and add specific simple functionality to it. For instance, you might set yourself the goal of modifying the IDE driver in the Linux kernel so that it turns on a
첫 번째 직업 (및 모든 후속 직업)에는 기존 코드를 유지 관리하는 것이 사실상 확률적으로 당연할 것입니다. 정확하게 문서화되고 잘 주석 처리 된 코드를 보는 것은 운이 정말 좋은 것이며, 개인적인 나의 경험처럼 주석이 전혀없는 거나 하나의 주석을 추가하거나 제거하하면 예상하지 못한 컴파일 에러가 생기거나 내부 에러가 생기는 코드를 보게 될 수도 있습니다. 내가 찾은 가장 유용한 학습 기술은 오픈 소스 프로젝트를 가져 와 간단한 기능을 추가해 보는 것입니다. 예를 들어 리눅스 커널의 IDE driver를 수정하는 것을 목표로 할 수도 있습니다.

A general disadvantage of learning in the school context is that you know that the problem you've been assigned has a solution, you know that you have been given the skills and the time to find that solution, and you can make inferences (from where your class is up to in the curriculum) as to which specific skills are likely to be relevant to the problem. Real-world problems don't have any of these guarantees or hints; you're on your own with a clock (and budget) steadily ticking away and management breathing down your neck. Enjoy your time at school; these are the easiest problems you will ever be asked to solve.
학교 학습의 일반적인 단점은 당신이 할당 된 문제에 해결책이 있다는 것을 알고, 기술과 그 해결책을 찾을 수 있는 시간을 얻었고, 추론을 할 수 있다는 것을 알고 있다는 것입니다.(당신의 수업은 커리큘럼이 짜져 있으니..) 어떤 특정 기술이 문제와 관련이 있을지 결정합니다. 현실 세계에서는 이러한 보장이나 힌트가 없습니다. 시간은 가지만 (그리고 돈도 없어지고) 경영진이 당신 바로 뒤에 지켜보고 있습니다.. 학교에서 즐거운 시간 보내십시오. 학교에서의 과제들은 당신이 풀어야 할 가장 쉬운 것들입니다.

red LED whenever a write operation is requested from the application layer, or a green LED for read operations. A more challenging project might be to take an open-source operating system, such as NetBSD or eCos, and port it to a new board. In any case, the goal is to understand enough of the existing code to know where to insert your changes and modify the code as nonintrusively as possible to avoid creating bugs.
쓰기 작업이 응용 프로그램 계층에서 요청 될 때마다 빨간색 LED 또는 읽기 작업에 녹색 LED가 표시됩니다. 더 어려운 프로젝트는 NetBSD 또는 eCos와 같은 오픈 소스 운영 체제를 사용하여 새 보드에 포팅하는 것입니다. 어쨌든, 목표는 기존 코드를 충분히 이해하여 변경 사항을 삽입 할 곳을 파악하고 가능하면 코드를 수정하여 버그를 만들지 않도록하는 것입니다.

Finally, most embedded engineers are going to need at least rudimentary laboratory skills. This includes being able to solder up prototypes and operate an oscilloscope, signal generator, and spectrum analyzer. The introduction you'll receive in college is probably adequate grounding in this; you'll gain much greater facility with experience, of course. In this day and age, it's also very useful to be able to work with surface-mount components. You can practice this very inexpensively on any junked piece of hardware — an old PC motherboard, a DVD player, or any similar board with lots of parts on it. 
마지막으로, 많은 임베디드 엔지니어들은 기본적인 연구소 기술을 익혀야 합니다. 그것들에는 프로토타입을 직접 납땜해서 만들 수 있다거나, 오실로스콥을 작동시키고, 시그널 생성기를 만지고, 스펙트럼 분석기를 쓸 수 있는 것들 입니다. 당신이 대학에서 받게 될 소개는 이것에서 적절한 접지 일 것입니다; 물론 훨씬 더 큰 편의 시설을 경험하게 될 것입니다. 이 시대에는 표면 실장 부품으로 작업하는 것이 매우 유용합니다 - 오래된 PC 마더 보드, DVD 플레이어 또는 그 위에 많은 부품이있는 유사한 보드를 사용 하는 것

I'm sure you've noted the recurring theme here: even if you learn some skills theoretically at school, I'm exhorting you to find opportunities to keep working at example problems requiring those skills in real life. Furthermore, a lot of what you need to know can only be acquired through dealing with actual problems. Engineering is a practical discipline. Steep yourself in homebrew projects to keep your skills fresh and ready for action; you're also demonstrating self-motivation to future employers.
당신은 지금까지 반복된 내용을 알았을 겁니다: 만약 학교에서 이론적으로 어떤 기술을 익혔을 지라도, 그 내용들을 실제 상황에서 볼 수 있는 기회를 찾기를 바랍니다. 많은 것들이 실제 경험을 통해서만 알 수 있습니다. 엔지니어링은 실질것인 것입니다. 신 기술에 적응하고 바로 실행할 수 있도록 하려면 자신을 숙성시키기 위해 노력을 해야 합니다. 당신은 미래 고용자들에게 어필을 하는 것입니다.


2017년 5월 2일 화요일

watchdog timer

A watchdog timer (sometimes called a computer operating properly or COP timer, or simply a watchdog) is an electronic timer that is used to detect and recover from computer malfunctions.

During normal operation, the computer regularly resets the watchdog timer to prevent it from elapsing, or "timing out".

If, due to a hardware fault or program error, the computer fails to reset the watchdog, the timer will elapse and generate a timeout signal.

The timeout signal is used to initiate corrective action or actions.

The corrective actions typically include placing the computer system in a safe state and restoring normal system operation.


Watchdog timers are commonly found in embedded systems and other computer-controlled equipment where humans cannot easily access the equipment or would be unable to react to faults in a timely manner.

In such systems, the computer cannot depend on a human to reboot it if it hangs; it must be self-reliant.

For example, remote embedded systems such as space probes are not physically accessible to human operators; these could become permanently disabled if they were unable to autonomously recover from faults.

A watchdog timer is usually employed in cases like these.

Watchdog timers may also be used when running untrusted code in a sandbox, to limit the CPU time available to the code and thus prevent some types of denial-of-service attacks.

reference
    Link 1: english Wikipedia
    Link 2: korean Wikipedia

2017년 4월 29일 토요일

(E)Silicon Labs C8051 LED Blinky Example Explained(C8051 chip 기본동작 LED 예제로 설명하기)

Purpose
for newbie(software engineer) to understand basic concept of embedded programming.
line by line explanation.

Preparation
board: C8051F560 Development Kit
part(Chip): C8051F568-ACK06Z
datasheet: C8051F55x/56x/57x
development kit document: C8051F560 DEVELOPMENT KIT USER ’S GUIDE
development Tool: Simplicity Studio v4
silicon labs debugger
PC(notebook)

Prerequisite
install simplicity studio v4
connect PC-board-debugger

Create (example) project
simplicity IDE - File - New - Project - Silicon Labs MCU Project
select board
select part
select project type:example
select f55x-57x Blinky
copy contents

Explanation
1. Program Description:
  This program flashes the green LED on the C8051F560 target board about
  five times a second using the interrupt handler for Timer2.

2. How To Test:
  1) Download code to the 'F560 target board
  2) Ensure that the P1.3 pins are shorted together on the J19 header
  3) Run the program.  If the LED flashes, the program is working
  J19: Side A: Connects P1.3_A LED and P1.4_A Switch to MCU port pins


3. Code:
  // Includes
  // Global CONSTANTS -> set system clock speed, and select pin to connect to LED
  // Function PROTOTYPES
  //// OSCILLATOR_Init -> set oscillator speed
  //// PORT_Init -> set pin to manipulate LED
  //// TIMER2_Init -> set timer speed, init(&reload) value, enable interrupt and start timer
  // Interrupt Service Routines
  //// Timer2_ISR -> set interrupt service routine function when timer executed
  // MAIN Routine -> initialize and execute while not to exit firmware.

4. line by line code explanation.
    1) Total 175 line of Code
        - 93 lines of Comments
        - 16 lines of new line
        - 66 line of (meaningful) code
    2) will be continued

37: #include <SI_C8051F550_Defs.h>
-> SFR(Special Function Register) address
-> (IRN) Interrupt Request Numbers

38: #include <SI_C8051F550_Register_Enums.h>
-> Register Names

44: #define SYSCLK       24000000/8        // SYSCLK frequency in Hz
SYSCLK : System  Clock
Processor Clock: Chip Clock
-> more explanation needed
reference: Link

46: SBIT (LED, SFR_P1, 3);                 // LED='1' means ON
LED is variable to connect SFR_P1(port 1), pin 3 with rear LED.
so LED=1 make LED light on

52: void OSCILLATOR_Init (void);
initialize oscillator for oscillation of the crystal

53: void PORT_Init (void);
set pin to execute the chip for purpose
in this case LED pin

54: void TIMER2_Init (U16 counts);
configuration timer 2 to execute chip.
configure consists Interrupt Service Routine, Auto-reload, Timer base

59 ~ 75: Main
explained later

88 ~ 96: OSCILLATOR_Init function
88: void OSCILLATOR_Init (void)
89: {
90:    U8 SFRPAGE_save = SFRPAGE;
To read or modifying the SFR value, we need to contact the register.
the steps are
1. Select the appropriate SFR page number using the SFRPAGE register.
2. Use direct accessing mode to read or write the special function register (MOV instruction).

SFR has pages, for C8051F55x/56x/57x family of devices utilizes three SFR pages: 0x00, 0x0C, and 0x0F (ref: datasheet 12.1. SFR Paging)

91:    SFRPAGE = CONFIG_PAGE;
CONFIG_PAGE is 0x0F, and to modify OSCICN register this address should be accessed
92:
93:    OSCICN = 0xC4;                      // Set oscillator divide to /8
OSCICN: Internal Oscillator Control
0xC4 saids 100: SYSCLK derived from Internal Oscillator divided by 8.
datasheet saids SFR Address = 0xA1; SFR Page = 0x0F
so this makes system clock to 24000000(default) / 8 (line 44)
94:
95:    SFRPAGE = SFRPAGE_save;
return pre-sfrpage
96: }

111: void PORT_Init (void)
112: {
113:    U8 SFRPAGE_save = SFRPAGE;
114:    SFRPAGE = CONFIG_PAGE;
115:
116:    P1MDOUT |= 0x08;                 // Enable LED as a push-pull output
P1MDOUT was declared as
SFR (P1MDOUT,     0xA5); ///< Port 1 Output Mode
0xA5 address's value is assigned to P1MDOUT
to configure P1MDOUT(Port 1 mode Out)
it can be done with config2.exe
0x08 is 00001000 as binary and this means port 1 pin 3 is push-pull output
117:    P1SKIP  |= 0x08;                    // Skip the LED pin on the crossbar
skip port 1 pin 3 not to connect any peripheral
119:    XBR2     = 0x40;                    // Enable crossbar and weak pull-ups
see ref1 below
121:    SFRPAGE = SFRPAGE_save;
122: }

137: void TIMER2_Init (U16 counts)
138: {
139:    U8 SFRPAGE_save = SFRPAGE;
140:    SFRPAGE = LEGACY_PAGE;

142:   TMR2CN  = 0x00;                  // Stop Timer2; Clear TF2;
                                                 // use SYSCLK/12 as timebase
144:   CKCON  &= ~0x60;               // Timer2 clocked based on T2XCLK; <- same as above comment(SYSCLK/12 as timebase)

146:   TMR2RL  = -counts;              // Init reload values
timebase is 250,000 hz(250,000 cycles in 1 second)
counts value is 25,000(number, cycles) so
25,000 times takes 25,000 / 250,000 * 1seconds = 1/10 seconds.
this means 10hz frequency
147:   TMR2    = 0xFFFF;                // Set to reload immediately
148:   IE_ET2  = 1;                        // Enable Timer2 interrupts
149:   TMR2CN_TR2 = 1;               // Start Timer2

151:   SFRPAGE = SFRPAGE_save;
152:}

Timer 2
-> check the block diagram related to each register
-> understand datasheet register definition


166: INTERRUPT(TIMER2_ISR, TIMER2_IRQn)
when timer2 interrupt occurs(TIMER2_IRQn, 5 as constant) this TIMER2_ISR function(interrupt service routine) executed
167: {
168:    TMR2CN_TF2H = 0;               // Clear Timer2 interrupt flag
clear flag for next interrupt, because this function already executed.
169:    LED = !LED;                         // Change state of LED
LED represents LED pin
toggle means once on and once off when this interrupt service routine occurs
170: }

ref1: Link
Basically, it gives the designer the flexibility to chose which pins the desired peripheral is routed to. Let's say you have a UART devices that needs to connect to pins P1.0 and P1.1. The crossbar allows you to bring that signal out to that pin or a different supported pin in another design. Think of it as a multiplexer. Each physical pin is an output and all the peripherals are the inputs.

Hope that helps. Every micro controller has this sort of functionality, though usually a pin is limited to a few peripherals it can connect to. This is generally called "pin muxing".

2017년 4월 28일 금요일

Memory Types on Embedded Programming(Memory의 종류 및 고려해야 할 점)

Memory의 종류 및 고려해야 할 점

1. 전원을 차단 시 특성에 의한 구분
    1) 지워지는 것
        - RAM: Random Access Memory
    2) 지워지지 않는 것
        - ROM: Read Only Memory

2. 세부 종류
    1) RAM
        SRAM

    2) ROM
        Flash
        EEPROM

3. 메모리가 필요한 예시
    1) 전원이 꺼져도 없어지지 않아야 한다: 코드
    2) 프로그램 실행: 실제 실행되는 Binary -> 코드가 변환하여 Upload
    3) 프로그램 실행 시 사용되고, 전원이 꺼져도 없어지지 않아야 하는것: Setting 값 등

-> 설명: 코드는 전원이 꺼져도 없어지지 않아야 하니까 ROM 의 한 종류인 Flash 에 저장이 된다. 그리고 전원이 들어오면 실행이 되어야 하기 때문에 이 코드를 RAM Memory 에 올리고 MCU 가 실행 된다. 보통은 RAM 영역에서 실행하고 전원을 끄면 RAM의 내용이 지워지면 되지만 Setting 값 들(모니터의 밝기 등)은 저장되어 있는 것이 고객이 사용하기에 편리하기 때문에 이런 특성을 가진 변수를 저장할 때는 ROM의 한 종류인 EEPROM을 사용한다. EEPROM은 같은 ROM인 Flash에 비해 read/write 속도가 느리고 쓰는 횟수도 제한되어(10만번) 있다.

4. 실제 사용하고 싶은 MCU 를 선택 할 때 고려할 것
    - 사용할 코드의 크기 -> Flash
    - 실제 프로그램에 실행 시 RAM에 올릴 코드의 크기 -> SRAM
    - 전원이 꺼져도 계속 값이 유지되어야 하는 값들 -> EEPROM
    -> 동일 Family 의 MCU 라도 메모리 크기에 의한 Chip 이 따로 있는 이유이다.


참조: http://www.icbanq.com/pbloger/board_View.aspx?number=965

SRAM 은 DRAM에 비하여 5배 빠르며 비싸다.
Static의 의미는 전기를 주는 한 데이터가 지워지지 않는다는 의미이며, Dynamic은 1초마다 refresh(Capacitor에 전자를 채워 주는 것)를 해 줘야 데이터가 유지된다.
보통 MCU의 RAM에 SRAM만 있는 이유는 속도 때문이라고 생각한다.


참조: http://yeslab.tistory.com/20


용량이 큰 경우에는 돈이 중요하기 때문이다.

참조: http://terms.naver.com/entry.nhn?docId=1180951&cid=40942&categoryId=32832

flash 와 EEPROM의 비교

flash 는 싸며 빠르며 큰 block 단위로 지우고 쓸 수 있다.
EERPOM은 상대적으로 비싸며 느리며 작은 block 단위로 지우고 쓸 수 있다.
적은 크기의 데이터를 쓴다면 EEPROM 이 맞고 큰 크기의 데이터가 필요하며 flash 가 맞다.

flash 안에서도 program flash, data flash 를 나누어서 쓰고 있는데 말 그대로 프로그램 code가 저장되는 곳이 program flash 이며 사용할 데이터(setting 값 같은) 를 저장하는 곳이 data flash 이다.
EEPROM, program flash, data flash 중 어떤 것을 선택할지는 기능과 가격을 고려해서 사요할 것이며 유사 프로젝트에서 경험적으로 진행 할 것이라고 생각한다.

그리고 ROM(Read Only Memory) write 의 횟수가 적다는 의미이지(주로 사용하는 기능이 Read) write가 안된다는 말이 아니다.

참조1/2: https://en-sg.knowledgebase.renesas.com/English_Content/MCUMPU/Basic_Information/What_is_the_difference_between_%22program_ROM%22_and_%22data_flash%22%3F
참조2/2: https://en.wikipedia.org/wiki/Flash_memory

EEPROM 크기가 작기 때문에 필요한 경우가 많은데 가격이 비싸다 그래서 가격이 싼 flash memory를 EEPROM 과 같이 쓰기 위해서 emulation을 한다. 문제는 flash가 하나의 큰 블럭 단위로 지우고 쓰기 때문에 EEPROM 과 같이 작은 단위의 블록으로 활용하려면 이를 위한 알고리즘이 필요하다. 결국 flash memory를 하나의 블럭을 전부 쓴 다음에만 지우는 것이 필요하게 된다.

참조1/2: https://www.ecnmag.com/article/2007/09/benefits-flash-eeprom-re-programming-end-application-becomes-easy
참조2/2: https://electronics.stackexchange.com/questions/258851/flash-eeprom-emulation

DDR 도 RAM 으로 사용하는 메모리의 한 종류

Program Flash, Data Flash, SRAM 으로 기본 메모리가 이루어져 있고
이 중 Flash 에서 Flash NVM(64KB), SRAM 중에서 Flash RAM(4KB) 을 사용하여 EEPROM Emulation 을 진행한다 이렇게 되면 EEPROM 을 10년 사용할 수 있게 된다.

2017년 4월 17일 월요일

Simplicity(C 언어) 사용 시 Terminology

대상: Chip C8051-F560


CLI: Command Line Interface

HCI: Human–computer interaction

SMbus: The System Management Bus (abbreviated to SMBus or SMB) is a single-ended simple two-wire bus for the purpose of lightweight communication.

숫자 뒤의 'U'
C 언어에서 기본으로 int 이므로 뒤에 U 를 쓰면 unsigned 가 된다.
참조: http://stackoverflow.com/questions/9029974/what-does-u-mean-after-a-number

Interrupt
TCON: Timer Control
Edge/Level triggered interrupt 두 방법의 차이
Edge Trigger 는 rising 혹은 falling edge 가 발생할 때 interrupt 가 발생되는 것
Level Trigger 는 특정 Level이 될 때 interrupt 가 발생되는 것

참조: https://electronics.stackexchange.com/questions/21886/what-does-edge-triggered-and-level-triggered-mean

IT01CF: INT0/INT1 Configuration
IT01CF = 0x0E -> (00001110)
IN0PL: 1 => INT0 Polarity, 1: INT0 input is active high
IN0SL:  INT0 Port Pin Selection Bits
IN0SL[2:0]:110 =>  110: Select P1.6

Timer
When the 8-bit count overflows, the output signal is asserted. The output signal may thereby trigger an interrupt at the processor or set a bit that the processor can read. To restart the timer, software reloads the count register with the same or a different initial value.
참조: http://www.embedded.com/electronics-blogs/beginner-s-corner/4024440/Introduction-to-Counter-Timers


vector
http://www.keil.com/forum/6306/
https://en.wikipedia.org/wiki/Interrupt_vector_table

SFR
Special Function Register:
SFR Page: pages when reading or modifying SFRs.
SFR Page[7:0] = 00001111 (control_page)
SFR Page[7:0] = 00000000 (active_page)


PCA (Programmable Counter Array)
PCA 주요특징.
• 16-bit time base.
• Programmable clock divisor and clock source selection.
• Up to three independently-configurable channels
• 8, 9, 10, 11 and 16-bit PWM modes (edge-aligned operation).
• Frequency output mode.
• Capture on rising, falling or any edge.
• Compare function for arbitrary waveform generation.
• Software timer (internal compare) mode.
• Integrated watchdog timer.
참조: http://igotit.tistory.com/296


Push-Pull/Open Drain 출력 설정
This answer is general to processors and peripherals, and has an SRAM specific comment at the end, which is probably pertinent to your specific RAM and CPU.

Output pins can be driven in three different modes:

• open drain - a transistor connects to low and nothing else
• open drain, with pull-up - a transistor connects to low, and a resistor connects to high
• push-pull - a transistor connects to high, and a transistor connects to low (only one is operated at a time)
• Input pins can be a gate input with a:

• pull-up - a resistor connected to high
• pull-down - a resistor connected to low
• pull-up and pull-down - both a resistor connected to high and a resistor connected to low (only useful in rare cases).
참조: https://electronics.stackexchange.com/questions/28091/push-pull-open-drain-pull-up-pull-down

crossbar
참조: https://www.reddit.com/r/AskElectronics/comments/1ggdd6/what_is_the_crossbar_in_a_microcontroller_and_how/


ASCII
0x0d : carriage return (\r)
0x0a : new line ( \n)


SBIT
SFR 에 개별적으로 접근하기 위한 방법

SBIT (TI0, SFR_SCON0, 1);              // UART0 TX Interrupt Flag
SBIT (RI0, SFR_SCON0, 0);              // UART0 RX Interrupt Flag

참조: http://www.fsinc.com/reference/html/com9agk.htm


Pin Configuration
핀 구성을 도와주는 프로그램이 들어 있다.
그 툴로 셋팅을 하면 Register를 셋팅하는 코드가 나오니 그 코드를 사용하면 된다.
Config2.exe

2017년 1월 15일 일요일

Datasheet 읽는 법

datasheet는 왜 중요할까요?

전자분야를 시작하는 사람에게 경험자들이 "Datasheet 먼저 읽어봐" 라고 하는 것을 듣게 됩니다.

왜 그렇게 datasheet가 중요한 것이며 그 datasheet에서 어떤 정보를 얻을 수 있는 것일까요?

하지만 결국 많은 경험이 있어야지만 Datasheet에서 많은 내용을 얻을 수 있는것 같습니다. Datasheet를 처음부터 끝까지 읽는 것은 정말 도움이 되는 것일까요?

---

간단히 얘기하자면 Datasheet는 그 부품에 대한 완벽한 백과사전 입니다.

좋은 Datasheet는 당신이 알아야 할 모든 것을 이야기 해 줄 것입니다. 그 정보를 이용 하세요.

많은 Design Error는(그 부품을 사용한 시스텡의) 그 부품의 Datasheet에 적혀있는 Spec을 대충(고의이건 아니건 간에)보았기 때문 입니다.

가장 분명한 사실은 datasheet는 Pin 들을 보여준다는 것입니다, 그래서 당신은 어떻게 Pin 을 연결해야 할 지 알 수 있습니다.

144개 Pin이 있는 Controller 라면 datasheet 없이는 어떻게 연결해야 할 지 알 수 없는것은 당연 합니다.

그리고 Datasheet가 있어도 간단한 diode 회로도 정도가 있어야 합니다.

Pin Configuration
Absolute Maximum Rating
Voltage and Current rating: power supply range,

추가 정리 필요.

Link

2016년 7월 29일 금요일

MCU SW 공부 1 - Clock, Timer, Counter, Prescaler 개념 비교


Micro Controller Unit(이하 MCU) 을 분석하는 과정은 다음과 같다(알고 있는 수준에서)

1. MCU를 선택 한다.
    - 어떤 기능을 수행해야 하는지
    - 거기에 맞는 Spec을 가진 MCU는 무엇이 있는지
    - 사용가능 MCU 중 가장 저렴한 것은 무엇인지

2. 실행 주기 선택 한다.
    - MCU는 혼자 실행 될 수도 있고, 다른 MCU와 연동해서 사용할 수도 있다.
    - 그리고 외부 ECU 와 연동될 수도 있다.
    - 그렇게 때문에 최소 실행주기 및 특정 기능들의 실행 주기를 선택해야 한다.

3. 기능을 구현하여 실행 시킨다.
    - 2번에서 정한 특정 주기마다 실행 될 함수를 구현한다.
    - 특정 주기마다 실행 되는 함수는 Call Back Function, Interrupt Service Routine, Task 등 여러가지로 불릴 수 있다..


아직 1번 어떤 MCU를 선택해야 하는지는 시스템 전체를 볼 수 있는 눈이 없기 때문에 보류하고,
3번 실행되는 기능은 요구사항에 맞추어 세부적으로 구현이 들어가는 것인데 이 세부를 보기 전에 주기적으로 꼭 실행되어야 하는 함수들이 무엇인지 결정되어야 한다.
그것이 2번 실행 주기를 선택하는 것이다.

Clock은 MCU 동작의 기준이 되는 시계이다.
일정한 시간 간격으로 0과 1의 값이 번갈아 나타난다.

그 Clock 의 개수를 세어 주는 것이 Counter 이다.
8bit Counter 는 8개 bit 만큼 셀 수 있다.
2^8 = 256 이므로 8bit Counter 는 0~255 까지 셀 수 있다.
이 Counter의 값과 비교하여 특정 조건이 되면 Interrupt를 실행시킬 수 있는데
이 방법에 따라

오버플로우 인터럽트: 카운터의 값이 오버플로우 되는 겨우 발생
출력비교 인터럽트: 카운터 값이 출력비교 레지스터의 값과 같게 되는 순간에 발생
입력 캡쳐 인터럽트: 입력이 들어올 경우 발생, 그리고 그때의 시간을 저장

등의 방식으로 동작할 수 있다. 각 인터럽트가 걸렸을 때 이미 등록해 놓은 특정 함수가 실행될 수 있는 것이다.

Counter 라는 단어의 의미를 보았지만 비슷한 의미로 Timer 도 쓰인다.
이 둘의 차이는

Timer: MCU 내부 클럭을 세는 장치
Counter: MCU 외부에서 입력되는 클럭을 세는 장치

Timer/Counter라고 같이 사용되는곳이 많은(검색 시 다수가 그렇게 표현) 같은 의미라고 이해해될 될 것이라고 생각.

-- Prescaler 추가 --
개발자는 필요한 시간 단위가 있는데 MCU 의 clock 주파수가 높아 그 시간을 못맞출 수 있다.
8MHz 의 system clock 을 가지고 있다면 timer 의 clock 기본 주기는 0.125us 이 된다.
(1 Second * 1000 * 1000 / 8,000,000Hz = 0.125us)
실제 필요한 동작단위가 1us 라면 8 이라는 prescaler 값이 필요한 것이다.

-- hertz(hz) 추가 --
진동 현상이 있을 때 1초에 몇 번의 왕복 운동이 있는지 나타내는 단위
주기적으로 반복되는 모든 현상에 일반적으로 쓰일 수 있다.

보통 가정집에 들어오는 교류 전원은 220V, 60Hz 인데 교류 전압을 1초 동안 60번 0V를 기준으로 (-110~+110 까지) 오르락 내리락 하며 사인 진동을 반복한다.

컴퓨터 CPU 클럭을 얘기할 때 헤르츠 단위를 쓰는 이유는 무엇일까? CPU가 일정한 속도로 동작하기 위해서는 일정한 간격으로 전기적 펄스를 공급 받아야 하는데 이 전기적 펄스가 초당 CPU에 공급되는 횟수라는 개념에서 Hz라는 단위를 쓴다.

2016년 3월 10일 목요일

(K)디지털 통신의 1차 분류(Serial-Parellel, 직렬-병렬)

디지털 통신 시스템에서는 두 가지의 데이터 전송 방식이 있다:병렬 과 직렬. 병렬 연결은 여러개의 선이 병렬로(동시에) 동작하는 거시고. 시리얼은, 반대로, 하나의 선으로 데이터를 하나씩 전송하는 것이다.

병렬 데이터
컴퓨터에 있는 병렬 포트가 예시이다. 병렬 포트의 경우 8개의 데이터 선들이 있고, 그라운드선과, 제어선이 있다. 그리고 IDE 하드디스크 커넥터와 PCI 확장포트도 좋은 예이다.

직렬 데이터
컴퓨터의 직렬 포트가 예시이다. 하나의 선으로 연결이 되어 있거나 하나의 차동증폭기로 되어 있고, 기본 선 외에 그라운드나 컨트롤 선이 있는 것이다. USB, FireWire, SATA 와 PCI Express 가 좋은 예이다.


참조: https://en.wikibooks.org/wiki/Communication_Networks/Parallel_vs_Serial