Hệ thống nhúng - Chương 3
Số trang: 21
Loại file: ppt
Dung lượng: 393.00 KB
Lượt xem: 13
Lượt tải: 0
Xem trước 3 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Flight plan:• In this lesson we will review all the numerical datatypes offered by the MPLAB® C30 compiler.• We will learn how much memory the compilerallocates for the numerical variables and we willinvestigate the relative efficiency of the routinesused to perform arithmetic operations by using theMPLAB• SIM Stopwatch as a basic profiling tool. Thisexperience will help you choose the “right”numbers for your embedded-control application,understanding when and how to balanceperformance and memory resources, real-timeconstraints and complexity....
Nội dung trích xuất từ tài liệu:
Hệ thống nhúng - Chương 3Embedded Systems Hệ thống nhúng Thạc sĩ Lê Mạnh Hải 1 Lesson 3:NUMBERSFlight plan:• In this lesson we will review all the numerical data types offered by the MPLAB® C30 compiler.• We will learn how much memory the compiler allocates for the numerical variables and we will investigate the relative efficiency of the routines used to perform arithmetic operations by using the MPLAB• SIM Stopwatch as a basic profiling tool. This experience will help you choose the “right” numbers for your embedded-control application, understanding when and how to balance performance and memory resources, real-time constraints and complexity. 2 Preflight checklist• MPLAB IDE, Integrated Development Environment• MPLAB SIM, software simulator• MPLAB C30 compiler (Student Version) 3 The flight1. MPLAB C30 User Guide 4 The flightunsigned long i,j,k;main (){i = 0x1234; // assign an initial value to ij = 0x5678; // assign an initial value to jk = i * j; // perform the product and store the result in k} 5Assembly code 6 On optimization (or lack thereof)• In fact, the compiler does not see things this clearly—its role is to create “safe” code, avoiding (at least initially) any assumption and using standard sequences of instructions.• Later on, if the proper optimization options are enabled, a second pass (or more) is performed to remove the redundant code.• During the development and debugging phases of a project, though, it is always good practice to disable all optimizations as they might modify the structure of the code being analyzed and render single-stepping and breakpoint placement problematic. 7 Testing• Set the cursor on the first line containing the initialization of the first variable, and perform a Run To Cursor command to let the program initialize and stop the execution just before the first instruction we want to observe.• Open the Watch window (“View→Watch”) and select WREG0 in the SFR selection box, then click on the “Add SFR” button.• Repeat the operation for WREG1.• Select “i” in the symbol selection box, and click on the “Add Symbol” button.• Repeat the operation for j and k.• Use the “Step Over” function to execute the next few program lines, observing the effects on the registers and variables in the Watch window. As we noted before, when the value of a variable in the Watch window changes, it is conveniently highlighted in red. 8 Post-flight briefing• In this lesson, we have learned not only what data types are available and how much memory is allocated to them, but also how they affect the resulting compiled program—code size and the execution speed.• We used the MPLAB SIM simulator Stopwatch function to measure the number of instruction cycles (and therefore time) required for the execution of a series of code segments.• Some of the information gathered will, hopefully, be useful to guide our actions in the future when balancing our needs for precision and performance in embedded-control applications. 9 Interrupts• What is Interrupts?• Why does ES need more and more Interrupts?• How does Interrupts work?• How can we control Interrupts? 10 Flight plan• How the MPLAB® C30 compiler allows us to easily manage the interrupt mechanisms offered by the PIC24 microcontroller architecture.• After a brief review of some of the C language extensions and some practical considerations, we will present a short example of how to use the secondary (low-frequency) oscillator to maintain a real-time clock. 11 Preflight checklist• MPLAB IDE,• MPLAB C30 compiler and the MPLAB SIM simulator.• Use the “New Project Set-up” checklist to create a new project called “Interrupts” and a new source file similarly called “interrupts.c”. 12 The flight• The PIC24 architecture provides a rich interrupt system that can manage as many as 118 distinct sources of interrupts.• Each interrupt source can have a unique piece of code, called the Interrupt Service Routine (ISR) directly associated via a pointer, also called a “vector,”• Interrupts can be completely asynchronous with the execution fl ow of the main program. They can be triggered at any point in time and in an unpredictable order. Therefore, the goal is to minimize the interrupt latency, defined as the time between the triggering event and the execution of the fi rst instruction of the Interrupt Service Routine (ISR).• In the PIC24 architecture, the latency is not only very short but it is also fixed for each given interrupt source—only three instruction cycles for internal events and four instruction cycles for external events. 13 PIC24F Interrupt• Up to 8 processor exceptions and software traps• 7 user-selectable priority levels• Interrupt Vector Table (IVT) with up to 118 vectors• A unique vector for each interrupt or exception source• Fixed priority within a specified user priority level• Alternate Interrupt Vector Table (AIVT) for debug support• Fixed interrupt entry and return latencies ...
Nội dung trích xuất từ tài liệu:
Hệ thống nhúng - Chương 3Embedded Systems Hệ thống nhúng Thạc sĩ Lê Mạnh Hải 1 Lesson 3:NUMBERSFlight plan:• In this lesson we will review all the numerical data types offered by the MPLAB® C30 compiler.• We will learn how much memory the compiler allocates for the numerical variables and we will investigate the relative efficiency of the routines used to perform arithmetic operations by using the MPLAB• SIM Stopwatch as a basic profiling tool. This experience will help you choose the “right” numbers for your embedded-control application, understanding when and how to balance performance and memory resources, real-time constraints and complexity. 2 Preflight checklist• MPLAB IDE, Integrated Development Environment• MPLAB SIM, software simulator• MPLAB C30 compiler (Student Version) 3 The flight1. MPLAB C30 User Guide 4 The flightunsigned long i,j,k;main (){i = 0x1234; // assign an initial value to ij = 0x5678; // assign an initial value to jk = i * j; // perform the product and store the result in k} 5Assembly code 6 On optimization (or lack thereof)• In fact, the compiler does not see things this clearly—its role is to create “safe” code, avoiding (at least initially) any assumption and using standard sequences of instructions.• Later on, if the proper optimization options are enabled, a second pass (or more) is performed to remove the redundant code.• During the development and debugging phases of a project, though, it is always good practice to disable all optimizations as they might modify the structure of the code being analyzed and render single-stepping and breakpoint placement problematic. 7 Testing• Set the cursor on the first line containing the initialization of the first variable, and perform a Run To Cursor command to let the program initialize and stop the execution just before the first instruction we want to observe.• Open the Watch window (“View→Watch”) and select WREG0 in the SFR selection box, then click on the “Add SFR” button.• Repeat the operation for WREG1.• Select “i” in the symbol selection box, and click on the “Add Symbol” button.• Repeat the operation for j and k.• Use the “Step Over” function to execute the next few program lines, observing the effects on the registers and variables in the Watch window. As we noted before, when the value of a variable in the Watch window changes, it is conveniently highlighted in red. 8 Post-flight briefing• In this lesson, we have learned not only what data types are available and how much memory is allocated to them, but also how they affect the resulting compiled program—code size and the execution speed.• We used the MPLAB SIM simulator Stopwatch function to measure the number of instruction cycles (and therefore time) required for the execution of a series of code segments.• Some of the information gathered will, hopefully, be useful to guide our actions in the future when balancing our needs for precision and performance in embedded-control applications. 9 Interrupts• What is Interrupts?• Why does ES need more and more Interrupts?• How does Interrupts work?• How can we control Interrupts? 10 Flight plan• How the MPLAB® C30 compiler allows us to easily manage the interrupt mechanisms offered by the PIC24 microcontroller architecture.• After a brief review of some of the C language extensions and some practical considerations, we will present a short example of how to use the secondary (low-frequency) oscillator to maintain a real-time clock. 11 Preflight checklist• MPLAB IDE,• MPLAB C30 compiler and the MPLAB SIM simulator.• Use the “New Project Set-up” checklist to create a new project called “Interrupts” and a new source file similarly called “interrupts.c”. 12 The flight• The PIC24 architecture provides a rich interrupt system that can manage as many as 118 distinct sources of interrupts.• Each interrupt source can have a unique piece of code, called the Interrupt Service Routine (ISR) directly associated via a pointer, also called a “vector,”• Interrupts can be completely asynchronous with the execution fl ow of the main program. They can be triggered at any point in time and in an unpredictable order. Therefore, the goal is to minimize the interrupt latency, defined as the time between the triggering event and the execution of the fi rst instruction of the Interrupt Service Routine (ISR).• In the PIC24 architecture, the latency is not only very short but it is also fixed for each given interrupt source—only three instruction cycles for internal events and four instruction cycles for external events. 13 PIC24F Interrupt• Up to 8 processor exceptions and software traps• 7 user-selectable priority levels• Interrupt Vector Table (IVT) with up to 118 vectors• A unique vector for each interrupt or exception source• Fixed priority within a specified user priority level• Alternate Interrupt Vector Table (AIVT) for debug support• Fixed interrupt entry and return latencies ...
Tìm kiếm theo từ khóa liên quan:
hệ thống nhúng tải liệu hệ thống nhúng lý thuyết nhúng lập trình nhúng kỹ thuật lập trìnhGợi ý tài liệu liên quan:
-
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 244 0 0 -
NGÂN HÀNG CÂU HỎI TRẮC NGHIỆM THIẾT KẾ WEB
8 trang 179 0 0 -
Giới thiệu môn học Ngôn ngữ lập trình C++
5 trang 177 0 0 -
Luận văn: Nghiên cứu kỹ thuật giấu tin trong ảnh Gif
33 trang 146 0 0 -
Bài giảng Nhập môn về lập trình - Chương 1: Giới thiệu về máy tính và lập trình
30 trang 143 0 0 -
Đề cương chi tiết học phần Vi điều khiển
15 trang 126 0 0 -
Báo cáo thực tập Công nghệ thông tin: Lập trình game trên Unity
27 trang 113 0 0 -
Giáo trình về phân tích thiết kế hệ thống thông tin
113 trang 112 0 0 -
26 trang 110 0 0
-
LUẬN VĂN: Tìm hiểu kỹ thuật tạo bóng cứng trong đồ họa 3D
41 trang 104 0 0