Download presentation
Presentation is loading. Please wait.
Published byJocelin Montgomery Modified over 9 years ago
1
ENTC-489 Embedded Real Time Software Development Embedded Real Time Software Development Week 1 Introduction Week 1 - Introduction (Rev 2) 1
2
ENTC-489 Embedded Real Time Software Development Today’s Agenda House Keeping Real Time Kernel Concepts Introduction to our development platform Preparation for first homework assignment Week 1 - Introduction (Rev 2) 2
3
ENTC-489 Embedded Real Time Software Development House Keeping Instructor Goals for this class Expectations / Grading Week 1 - Introduction (Rev 2) 3
4
ENTC-489 Embedded Real Time Software Development Instructor Mike Willey – BSEE Texas A&M ’78 – Second Aggie in family, first was Eugene Couch, BSME ‘1897 – 36 years designing embedded systems – Co-owner, CTO Paragon Innovations, Inc. – 30 years programming in C and using embedded kernels Week 1 - Introduction (Rev 2) 4
5
ENTC-489 Embedded Real Time Software Development Goals for this class Develop skills that will enable you to get and keep a job designing embedded systems firmware – Demonstrate knowledge of the vocabulary of Embedded Kernels – Demonstrate an understanding of memory sharing, dynamic allocation/de-allocation, and stack usage in an embedded design – Demonstrate an ability to use binary semaphores, counting semaphores, and message queues – Demonstrate an ability to design a multi-tasking embedded application using diagrams and text – Demonstrate a knowledge of defensive programming techniques – Design and implement a practical embedded application with at least 5 tasks Week 1 - Introduction (Rev 2) 5
6
ENTC-489 Embedded Real Time Software Development Expectation / Support / Grading Midterm Exam (Open Book)25% Final Exam (Open Book)25% Quizzes / Homework25% 5 Task Application Project25% Total100% Week 1 - Introduction (Rev 2) 6 A 90-100, B 80-89, C 70-79, D 60-69, F < 60 My expectation is that the software you write for this class will be the same quality that a professional engineering company would require of any technical contributor.
7
ENTC-489 Embedded Real Time Software Development Expectations / Support / Grading (cont) Software Application Grading – 55% Performs required functions – 5%No compiler warnings – 15%Proper use of highlighted techniques – 15%Design documentation / comments – 10%Conforms with Class Coding Standards – Bonus opportunities (must get full points for “Performs required functions”, max +10%) 5%Use processor I/O registers directly rather than Tiva Ware calls 5%Use of Doxygen to document program Week 1 - Introduction (Rev 2) 7
8
ENTC-489 Embedded Real Time Software Development Bonus Opportunities Use Processor I/O registers rather than TivaWare calls – Can use TivaWare as a go-by, but DO NOT Xerox! – Keep in separate source/include files – May use TivaWare “inc/*.h” but not “driverlib/*.h” Use Doxygen – Every function created by you MUST have a Doxygen entry for description, parameters and return values – All #defines and globals must have a description – The descriptions must be “useful” to aid in understanding and use. Week 1 - Introduction (Rev 2) 8
9
ENTC-489 Embedded Real Time Software Development Expectations / Support / Grading (cont) Class Support Site – http://txwilley.com/entc-489-ERTSD Contains my blog, instructions for setting up tools, handy resources, class coding standards, etc. http://txwilley.com/entc-489-ERTSD Software homework – CCS File->Export->General->Archive File File name for Jane Smith, Assignment “Blinky” s15_jsmith_blinky.zip Supply on a flash drive to be returned following week or Upload to http://txwilley.com/entc-489-ERTSDhttp://txwilley.com/entc-489-ERTSD – Requires registration on the web site Registration may take 24-48 hours for approval Week 1 - Introduction (Rev 2) 9
10
ENTC-489 Embedded Real Time Software Development Real Time Kernel Concepts Superloops Foreground/Background Systems Real-Time Kernels Week 1 - Introduction (Rev 2) 10
11
ENTC-489 Embedded Real Time Software Development Superloops Week 1 - Introduction (Rev 2) 11 Task 1Task 2Task 3Task 4
12
ENTC-489 Embedded Real Time Software Development Superloops void main (void) { initialization_code(); while (1) { read_adc(); read_serial_command(); write_serial_results(); for (i=0; i < bigvalue; i++) { /* delay to synchronize read_adc() */ } Week 1 - Introduction (Rev 2) 12
13
ENTC-489 Embedded Real Time Software Development Superloops Pros Easy for very simple stuff No upfront cost Minimal training No extra memory for OS Cons Difficult to catch external events Complexity grows quickly Timing is impossible to predict Week 1 - Introduction (Rev 2) 13
14
ENTC-489 Embedded Real Time Software Development Foreground/Background Systems Week 1 - Introduction (Rev 2) 14 Task 1 ISR #1 ISR #2 Task 2#3 Task 4
15
ENTC-489 Embedded Real Time Software Development Foreground/Background Systems Background void main (void) { perform_initialization(); while (1) { read_adc(); read_serial_command(); write_serial_result(); wait_timer_flag(); clear_timer_flag(); } Foreground void serial_isr(void) { clear_irq(); store_received_char(); } void timer_isr (void) { clear_irq(); set_timer_flag(); } Week 1 - Introduction (Rev 2) 15
16
ENTC-489 Embedded Real Time Software Development Foreground/Background Systems Pros No upfront cost Minimal training required Single stack area for – Function nesting – Local variables – ISR nesting No extra memory for OS Minimal interrupt latency Cons Difficult to ensure timing is met All background code has same priority If one function takes longer than expected, the whole system will suffer Complexity increases as the number of background tasks increases Week 1 - Introduction (Rev 2) 16
17
ENTC-489 Embedded Real Time Software Development Kernel Operating System vs. Kernel Week 1 - Introduction (Rev 2) 17 Application Hardware File System GUI TCP/IP USB Bluetooth RS-232 An Operating System is a collection of software that provides services useful to Application code. A Kernel provides task scheduling and communication for the other Operating System components and the Application.
18
ENTC-489 Embedded Real Time Software Development Real-Time If a task must be completed within a given time, it is said to be a real-time task – In other words, the task has a deadline There are two categories of real-time tasks – Hard Real-time tasks Missing the deadline results in a severe problem. For these tasks a late response is equivalent to an incorrect response – Soft Real-time tasks Missing a deadline does not cause dire consequences Week 1 - Introduction (Rev 2) 18
19
ENTC-489 Embedded Real Time Software Development Determinism Fast software is not necessarily real-time software Determinism is a desirable quality in real-time software Software is deterministic if it has a bounded response time to events Week 1 - Introduction (Rev 2) 19
20
ENTC-489 Embedded Real Time Software Development Real-Time Kernel A real-time kernel is a framework for developing multi-task applications The services provided by a real-time kernel can help an application meet its timing requirements The primary service provided by any real-time kernel is task scheduling Week 1 - Introduction (Rev 2) 20
21
ENTC-489 Embedded Real Time Software Development Real-Time Kernel Pros Simplifies complex systems Creating time-deterministic software is more straight forward Adding functionality has minimum impact on existing code Very easy for multiple contributors to work in same code base Cons Up front cost or port of open source code Requires design prior to coding Consumes extra memory Week 1 - Introduction (Rev 2) 21
22
ENTC-489 Embedded Real Time Software Development What is a task? A task is a simple program that thinks it has the CPU all to itself. A task will have a priority, based on its importance Week 1 - Introduction (Rev 2) 22 Task (Priority) CPU Registers Variables Arrays Structures I/O Devices Stack (RAM) (Optional)
23
ENTC-489 Embedded Real Time Software Development Tasks in a Kernel-Based System Week 1 - Introduction (Rev 2) 23 High Priority Task Low Priority Task Task Event Each Task Infinite Loop Importance
24
ENTC-489 Embedded Real Time Software Development Kernel Based System Tasks void read_ADC_task( void ){ while (1) { wait for conversion time; start A/D conversion; wait for signal from ISR; store_store_ADC_value(); } void read_serial_task (void) { while (1) { wait for character; if (not end of line) { put character in buffer; } else { process command; clear buffer; } ISRs void timer_irq (void) { clear interrupt; signal conversion time; } void adc_irq (void) { clear interrupt; signal conversion complete; } void serial_irq (void) { clear interrupts; signal character ready; } Week 1 - Introduction (Rev 2) 24
25
ENTC-489 Embedded Real Time Software Development Real Time Kernel Types A cooperative kernel (non-preemptive) relies on each task to relinquish the use of the CPU on a regular basis A preemptive kernel evaluates the highest priority task when returning from interrupt routines and resumes the highest priority task, rather than the one which was interrupted Week 1 - Introduction (Rev 2) 25
26
ENTC-489 Embedded Real Time Software Development Cooperative Kernels Week 1 - Introduction (Rev 2) 26 ISR Low-priority task High-priority task ISR Via a kernel call, the ISR makes the high priority task ready ISR completes The low-priority task completes and the kernel switches to the high-priority task Interrupt occurs Time
27
ENTC-489 Embedded Real Time Software Development Preemptive Kernels Week 1 - Introduction (Rev 2) 27 ISR Low-priority task High-priority task ISR Interrupt occurs ISR completes and the kernel switches to the high-priority task Via a kernel call, the ISR makes the high priority task ready The kernel switches to the low-priority task Time
28
ENTC-489 Embedded Real Time Software Development Week 1 - Introduction (Rev 2) 28 Task States
29
ENTC-489 Embedded Real Time Software Development BREAK Week 1 - Introduction (Rev 2) 29
30
ENTC-489 Embedded Real Time Software Development Intro to Tiva Development Tiva T4C123G Launch Pad is REQUIRED Sensor Hub Booster Pack is REQUIRED Code Composer Studio 6 is REQUIRED Install the tools on your PC txwilley/ENTC-489-ERTSD and go to the “Getting Started” tab Installation is time consuming, start early First homework assignment will take some time, order you boards ASAP Week 1 - Introduction (Rev 2) 30
31
ENTC-489 Embedded Real Time Software Development TMC123G Launch Pad Debug USB on top Power switch right is “on” for debug RGB Led 2 Push Buttons TM4C123GH6PM CPU UART 0 to Debug USB Port Week 1 - Introduction (Rev 2) 31
32
ENTC-489 Embedded Real Time Software Development Sensor Hub Booster Pack MPU9150 9 Axis Motion Sensor TMP006 Thermopile Sensor SHT21 Humidity Sensor BMP180 Pressure Sensor ISL29023 Light Sensor User LED Week 1 - Introduction (Rev 2) 32
33
ENTC-489 Embedded Real Time Software Development TM4C123GH6PM CPU Week 1 - Introduction (Rev 2) 33
34
ENTC-489 Embedded Real Time Software Development System Control Power on, runs on internal 16 MHz osc, PLL off, /16: 1 MHz instruction cycle We will run at 50MHz using the external 16 MHz crystal Week 1 - Introduction (Rev 2) 34
35
ENTC-489 Embedded Real Time Software Development Changing the Clock Registers: RSS RSS2 Week 1 - Introduction (Rev 2) 35
36
ENTC-489 Embedded Real Time Software Development Changing the Clock #include “inc/hw_types.h” – HWREG(), HWREGH(), HWREGB(), HWREGBITW(), HWREGBITH(), HWREGBITB() Using TivaWare – #include “driverlib/sysctl.h” – SysCtlClockSet(); Week 1 - Introduction (Rev 2) 36
37
ENTC-489 Embedded Real Time Software Development Timing on the TM4C123G In this class we DO NOT USE TIMING LOOPS (except when adjusting the system clock, making timing loops the only reasonable method of introducing a delay) ARM Devices provide a special periodic timer, SYSTICK specifically to provide a regular timer tick. – Point interrupt vector to FAULT_SYSTICK (this can be done in the *_startup_css.c file) – Set the number of clock ticks between interrupts in the NVIC_ST_RELOAD register – Enable the interrupts – Enable the systick device – Using TivaWare SysTickIntRegister(); /* optional */ SysTickPeriodSet(); IntMasterEnable(); SysTickIntEnable(); SysTickEnable(); – DANGER, WILL ROBINSON!!! use IntMasterDisable() instead of ROM_IntDisable(FAULT_SYSTICK) to disable interrupts while manipulating variables altered by your SYSTICK interrupt function. The later has the side effect of reloading the SYSTICK counter with the initial value. Week 1 - Introduction (Rev 2) 37
38
ENTC-489 Embedded Real Time Software Development GPIO Pins on the TM4C123G Steps to use a GPIO – Enable the clock to the GPIO port module (RCGC2) – Set the pad type (GPIO_O_DR2R, GPIO_O_DR4R, GIPO_O_DR8R, GPIO_O_SLR, GPIO_O_ODR, GPIO_O_PUR, GPIO_O_PDR, GPIO_O_DEN, GPIO_O_DIR, GPIO_O_AFSEL) Using TivaWare – SysCtlPeripheralEnable(); – GPIOPinTypeGPIOOutput(); GPIOPinTypeGPIOInput(); Week 1 - Introduction (Rev 2) 38
39
ENTC-489 Embedded Real Time Software Development Homework Start with BlankProject (No Operating System) from txwilley.com/entc-489-ERTSD Create a program that will – Blink the RGB LED in Blue (no red or green light) – Blink must be at 1Hz, that is 1 time per second the LED must turn on and off – Use a 50% duty cycle – Processor must run at 50MHz or faster – The functionality test for your grade will be Compiling on instructor’s workstation Running on instructor’s reference platform Required Techniques – Must use a timer interrupt to achieve time delays (no timing loops) Week 1 - Introduction (Rev 2) 39
40
ENTC-489 Embedded Real Time Software Development Closed Book Quiz Next Week Real-Time Software and Kernel Vocabulary Coding Standards Compliance Task State Diagram Superloop/Superloop with Interrupt/Kernel comparison Week 1 - Introduction (Rev 2) 40
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.