This action might not be possible to undo. Are you sure you want to continue?
“ Application using uC/OS-II on Stellaris® Guru Evaluation Kit for Teaching ARM® Cortex™- M3 and Embedded Systems”
VAISHNAV JAYKUMAR P. (E.C.-121) & THAKKAR SUKET J. (E.C.-116)
Under Supervision of
Department of Electronics & Communication, Faculty of Technology, Nadiad. Oct,2012
This is to certify that the project titled “Application using uC/OS-II on Stellaris®
Guru Evaluation Kit for Teaching ARM® Cortex™- M3 and Embedded Systems” by VAISHNAV JAYKUMAR P. & THAKKAR SUKET J. is a
bonafide work carried out by him under my guidance and supervision.
Prof. P.V. Patel Project Supervisor, Department of Electronics & Communication DDU , Nadiad.
Dr. N.J.Kothari Head, Department of Electronics & Communication DDU , Nadiad.
The goal of the project is to understand the features of Stellaris Guru Evaluation Kit and to port a Real Time Operationg System (RTOS) on it to do & understand multitasking. Three tasks are created and multitasking has been done to bring out the advantage of the RTOS , that is aading more intelligence and time accurate system. We are thankful to our project supervisor and head of department for including term project in 7th semester. It is very helpful in improving our fundamentals and also getting in touch with the new technology trends. Term project got very useful while dealing with company interviews. We are very thankful to Prof. M.J. Limachia sir who aspired to make project on this kit. We are also thankful to Prof. V.A.Vohra sir who has provided the guidance to fulfil the project on RTOS.
Vaishnav Jaykumar P.(EC-121) Thakkar Suket J.(EC-116)
e.UART etc.e. Since it‟s real time system it can be used in Vehicle Braking . PLC).APPLICATIONS OF PROJECT The project is used to do efficient multitasking between several tasks (i. temperature control . Toaster. Soft real time operations can be done successfully. MIC . for this kit). which in turn get useful getting knowledge about hard real time systems (i. . LED patterns .
9. 2. 3. 4. 5. 1. 10. Name of topic The Stellaris Guru kit Overview of ARM Cortex M3 Evolution of the ARM Instruction Set LM3S608 Microcontroller Features Components of kit Real Time System & Concepts Working of Semaphore Simulation in Keiluvision4 & Output Troubleshooting References Page No. 6. 1 . 7.CONTENTS No. 8.
7. 1. 6. Caption of figures Stellaris Guru Kit Kit components ARM Cortex M3 v/s ARM7TDMI Pin Out Diagram of LM3S608 Power supply Temperature Sensor and Potentiometer Task operations Task State Diagram Non-Preemptive Kernel Preemptive Kernel Synchronizing tasks and ISRs Tasks synchronizing their activities Screenshots Page No.LIST OF FIGURES No. Xyz . 9. 12. 11. 5. 13. 2. 3. 8. 10. 4.
.1 Kit Contents The kit box contains the following items: 1. Refer to the annotated Stellaris Guru Fig.3 What to Expect? When you connect the Stellaris Guru kit using the USB cable to your computer a few indicator LEDs turn on/flash indicating the board is in a ready to use state. both unicolor and RGB. The power indicator LED LD1 would be continuously on confirming the board is able to draw power from the USB.2 The Stellaris Guru Kit Fig.LM3S608) for locating the indicator LEDs. 1.1 Stellaris Guru Kit 1.4(Pin Out. 2.1.4 Features Overview • Based on LM3S608 microcontroller family from the TI Stellaris 600 series family. 1. The Stellaris Guru kit 1. LEDs LD3 and LD4 would light flash momentarily for a second confirming ability to establish serial connection with the computer. USB Cable 1. Stellaris Guru Kit 2. • User programmable push buttons and ultra[bright LEDs.
• Ambient light sensor using a LED operated in reverse bias. • UART0 accessible through a USB virtual COM port (VCP). • Standard ARM 20[pin JTAG debug connector. • Arduino compatible interface connector. Fig. • A LM35 temperature sensor for taking temperature readings using the Analog to Digital Convertor.• Reset pushbutton and power indicator LED. • Microphone amplifier with high gain and sensitivity connected to an independent ADC channel of the microcontroller. • USB interface for all communication and power.2 Kit components . • Programmable through UART using preinstalled boot loader. • Thumbwheel potentiometer for reading analog voltage through one of the ADC channels of the microcontroller.
• 32 bit data path. • • • • Raw interrupt performance: PID (process control) main loop: Multiply-intensive code: Divide-intensive code: 85% faster 217% faster 294% faster 726% faster . suitable for low power designs. • Harvard Architecture – separate instruction bus and data bus. • No switching between ARM state and thumb state. • Memory Protection Unit (MPU). • Configurable Nested Vector Interrupt Controller (NVIC). Overview of ARM Cortex M3 2. 2. • Advanced debug components. • Instruction fetches are 32 bits. As a result.1 Features • 32 bit microprocessor. • Thumb 2 instruction set. 32 bit register bank and 32 bit memory interfaces. there‟s more available bandwidth for data transfer. Up to two instructions can be fetched in one cycle.2 Benefits (ARM Cortex M3 v/s ARM7TDMI ) Capabilities beyond ARM7TDMI for the MCU market No Assembly Required! Cortex-M3 requires approximately half the Flash-memory of ARM7 implementations 2-4 times faster on MCU control applications. • ALU with hardware divide and single cycle multiply. • Operation Mode Selection – user and privilege modes. • 3 stage pipeline with branch speculation.2. • Low gate count. • Maximum of 240 external interrupts can be configured.
3 ARM Cortex M3 v/s ARM7TDMI Note: Dhrystone MIPS (DMIPS).Fig. Million Instructions Per Second (MIPS) .
As a result.3. Original 16 bit THUMB Instruction Set Subset of ARM Instructions Performs similar function as ARM instructions but in 16-bit code size. which are 32 bits and Thumb instructions. For ARM Instructions More 16-bit Thmb instructions are required to execute same functions compared to ARM instructions. code size and performance. but it can provide higher code density. hardware divide instruction is available on an ARM processor. the processor can be dynamically switched between the ARM state andt he Thumb state. Historically. The Thumb-2 instruction set is a very important feature of the ARMv7 architecture. two different instruction sets were supported on the ARM processor: the ARM instructions. But performance may be degraded. it uses Thumb-2 instruction set for all operations. Instead of using ARM instructions. as in traditional ARM processors. The Thumb-2 technology extended the Thumb Instruction Set Architecture (ISA) into a highly efficient and powerful instruction set that delivers significant benefits in terms of ease of use. Hence Introduction of Thumb-2 Instruction Set . The Thumb instruction set provides only a subset of the ARM instructions. It allows more complex operations to be carried out in the Thumb state. It is useful for products with tight memory requirements. with additional 16-bit instructions alongside 32-bit instructions. the Cortex-M3 processor is not backward compatible with traditional ARM processors. and a number of multiply instructions are also available. Evolution of the ARM Instruction Set Enhancement and extension of instruction sets used by the ARM processors has been one of the key driving forces of the architecture‟s evolution. During program execution. thus allowing higher efficiency by reducing the number of states switching between ARM state and Thumb state. The extended instruction set in Thumb-2 is a superset of the previous 16-bit Thumb instruction set. For the first time. which are 16 bits. The Cortex-M3 processor supports only the Thumb-2 (and traditional Thumb) instruction set. which use the ARM as well as Thumb instruction set.
1 Program Counter.25 DMIPS/MHz (Dhrystone MIPS) 12 Cycles • • • • • • Benchmark: Interrupt-Latency: Energy consumption: 0. MPU. 1 Program Status. Enhancement of 16-bit Thumb instructions with additional 32-bit instructions THUMB-2 Instruction Set • • • • Instruction Set: Word length: Architecture: Registers: Thumb2 32 bit Harvard (ARMv7-M) 13 general purpose. Debug functionality . Bit-Banding. 1 Link Register.19 mW/MHz Area 5]: 0. Special Registers 1. Sleep modes. 1 Stack Pointer.86mm2 (Core and Peripherals) Note: Does not include optional system peripherals (MPU & ETM) or integration level component Features: NVIC.
As one 32 bit Real time Clock. • ADC Eight analog input channels. • Internal Memory 32KB single cycle flash. providing a simple 24 bit clear on write. 23 interrupt with eight priority levels. 8KB single cycle SRAM. • General Purpose Timers Three general purpose timers modules each of which provides two 16 bit timers/counters. • ARM FiRM compliant Watchdog Timer. SysTick timer. • GPIOs 5 28 GPIOs. Thumb® compatible Thumb 2 only instruction set. Single ended and differential input configurations. wrap on zero counter.4. Fast toggle capable of a change every two clock cycle. 5V tolerant input configuration. For Pulse Width Modulation.LM3S608 Microcontroller Features • 32 bit RISC Performance 32 bit ARM® Cortex™ M3 v7 M architecture. 50 MHz Operation Integrated Nested Vector Interrupt Controller. decrementing. . Each can be conFigured independently: As a single 32 bit timer. Programmable control for GPIO pad configuration. Programmable control for GPIO interrupts. depending on configuration.
Separate 16x8 transmit (TX) and receive (RX) FIFOs to reduce CPU interrupt service loading. standard (100kbps) and Fast (400kbps). Programmable clock bit rate and operation.6. Programmable data frame size from 4 to 16 bits.On chip internal temperature sensor. Master and slave interrupt generation. Fully programmable serial interface characteristics 5. • I2C Devices on the I2C bus can be designated as either master or a slave.75V. generate an interrupt or initiate an ADC sample sequence.7 or 8 data bits. • Synchronous Serial Interface Master of Slave Operation. Sample rate of 500 thousand samples/second. Configurable for output to drive an output pin. • UART Two fully programmable 16C550 type UARTs.25V to 2. Even/Odd/Stick or No Parity generation. . Four I2C modes: Master transmit Mater receive Salve transmit Slave receive Two transmission speeds. 1 or 2 stop bit generation. • Analog Comparators One integrated analog comparator. • Power On chip Low Drop (LDO) voltage regulator with programmable output user adjustable from 2.
3.3V supply brownout detection and reporting via interrupt or reset. SAMPLE/PRELOAD. Software reset. The LM3S608 used on the kit is in the 48-pin Thin Quad FlatPackage (TQFP).Low power options on controller: Sleep and Deep Sleep Modes. Watchdog timer reset. Integrated ARM Serial Wire Debug (SWD). It follows the ARM Cortex-M 32-bit RISC architecture. Brownout (BOR) detector alerts to system power drops. • Flexible Reset Sources Power on Reset (POR) Reset pin assertion. Four bits Instruction Register (IR) chain for storing JTAG instructions. • JTAG IEEE 1149. Low power options for peripherals: software controls shutdown of individual peripherals. IEEE standard instructions: BYPASS.1 1990 compatible Test Access Port (TAP) controller. EXTEST and INTEST. The soul of the Stellaris Guru is the LM3S608 microcontroller. The pin assignment is shown is Figure 4. . IDCODE.
4 Pin Out Diagram of LM3S608 .Fig.
1 Power Supply The power supply section of the kit is shown below in Figure 5. ADC7 of the microcontroller.3 Temperature Sensor and Thumbwheel Potentiometer To evaluate the analog to digital conversion capabilities of the microcontroller. LED1 connected in series with the resistor R1 provides visual indication for power being supplied to the kit. Tantalum capacitors C1 and C2 provide input and output filtering respectively. a LM35 temperature sensor(IC6) and a thumbwheel potentiometer(POT1) are provided on the board. The two are connected to the same analog channel. Power is drawn directly from the USB bus of a computer. Bray++. The port can also be used to send UART values to a PC application. 5 Power supply 5. The LM35 is powered by +5V coming from the USB bus. Hyper Terminal. Either can be selected by using jumper J2. 5.3 (IC3) to generate +3. This helps in field programming of the microcontroller over UART using the supplied boot loader.3V required by the microcontroller and other kit components. which is at +5V potential. . etc. This voltage is then fed to a Low Drop Out voltage regulator LM1117[3.2 USB Virtual COM Port The Stellaris Guru kit uses a FT232RL (IC4) USB[to[Serial bridge connected between UART0 of the microcontroller and the USB.Components of kit 5. viz.5. Fig.
. LD6 and LD7. one RGB LED: RGB1 and two user pushbutton: S2 and S3. Choice can be made between the three unicolor LEDs and the RGB LED by placing the appropriate jumper on J1.4 I/O Peripherals – Switches and LEDs The kit consists of three unicolor LEDs: LD5. S2 and S3 are connected to PE0 and PE1 respectively. The anodes of all LEDs are connected to +3. 6 Temperature Sensor and Potentiometer 5.Fig. The LEDs are connected to the Capture/Compare/PWM (CCP) and hence can be used with Pulse Width Modulation for intensity control. PC6 and PC7 of the micro controller.3V. The cathodes of LEDs are connected to pins PC5.
regardless of system load There are two types of real-time systems: SOFT and HARD. This means that the computer is built into a system and is not seen by the user as being a computer. Definition: Real Time Systems are characterized by consequences that result if logical as well as timing correctness properties of the system are not met A real-time deadline must be met. Radio Transmissions. Most applications for real-time systems are embedded.. Types of RTOS: • Soft Real Time – Tasks are performed by the systems as fast as possible. etc. Most real-time systems have a combination of SOFT and HARD requirements. • Hard Real Time – Tasks have to be performed not only correctly but in time. Real Time System & Concepts Real-time systems are characterized by the fact that severe consequences will result if logical as well as timing correctness properties of the system are not met. Vehicle Braking. Online Ticket reservation systems.. – Video Surveillance. Real-time applications cover a wide range. Examples of embedded systems: Process control: Food processing Chemical plants Automotive: Engine controls Anti-lock braking systems Office automation: FAX machines Copiers Computer peripherals: Printers Terminals Scanners Modems Robots Aerospace: Flight management systems Weapons systems ... Failure to comply to the set deadlines would result catastrophical – Nucleur Reactors. but failing to complete within specified deadlines is not catastrophic.6. etc.
• Multitasking is like FG/BG with multiple BGs. Multitasking: • Multitasking is the process of scheduling and switching the CPU between several tasks. interrupts are typically disabled before the critical code is executed & enabled when the critical code is executed.Jet engine controls Domestic: Microwave ovens Dishwashers Washing machines Thermostats Task Level Response: • The time taken between the making a process ready to its execution is the Task Level Response • Critical operations have to be performed by ISR‟s to ensure that they are dealt in a timely fashion • Information for a BG module made available by an ISR is not processed until the background routine gets its turn to execute • The worst case task level response time depends on how long the BG loop takes to Execute. • • Each task should gain exclusive access to the shared resource to prevent data corruption. is a simple program that thinks it has the CPU all to itself. Resource & Shared Resource: • A resource is a entity used by the task. • It Provides Modular construction of Applications. a structure or an array. also called a thread. Advantages of Multitasking: • Maximizes the CPU Utilization. • A single CPU switches attention between several sequential tasks. • Must not be Interrupted. or a variable. • A resource can be a I/O device. . Critical Section of Code: • Also called as Critical region. • A shared resource is a resource that can be used by more than one task. • Should be treated indivisibly. • Application programs are typically easier to design & maintain if Multitasking is used. Task: • A task. • To ensure this.
• Each Task is assigned its own set of CPU Registers. Running Task: • A task is running when it has control of the CPU Waiting State: . Stack Area and a Priority.• Real Time application involves splitting the work to be done in Tasks.7: Task operations Task State: • DORMANT • READY • RUNNING • WAITING • ISR Note: Typically Tasks are infinite loops Dormant State: • Corresponds to the task that resides in the memory but has not been made available to the multitasking Kernel Ready State: • A task is READY when it can execute but its priority is less than the currently running task. Fig.
ISR State: • A task is in the ISR State when an interrupt has occurred and the CPU is in the process of servicing the Interrupt Figure:8 Task State Diagram Kernel: • Fundamental Service provided by the Kernel is Task Switching • Kernel simplifies the design of a system allowing the application to be divided into several tasks.• A Task is waiting when it requires a occurrence of a event (waiting for an I/O operation to complete. • Kernel adds overhead to the System(ROM & RAM) & also consumes CPU time(2-5%) Context Switch (Task Switch): • Save current CPU task‟s context (CPU Registers) on the current task‟s context storage area • The new task context is restored & start executing the new task • More the registers higher the overhead Task Priority: • A priority is assigned to each task • The more important the task the more the priority • Two types of priority assigning – Static (Assigned at Compile Time) – Dynamic (Assigned at Execution Time) Scheduler: . a timing pulse to occur. a shared resource to be available. time to expire etc).
• Part of the Kernel which will decide the next task to run • Most RT Kernels are priority based • Control is always given to highest priority task ready to run • Two types of priority based Kernels – Non-Preemptive – Preemptive Fig. .9 : Non-Preemptive Kernel Fig. 10: Preemptive Kernel Semaphores: • Control Access to a shared resource (ME) • Signal Occurrence of an event • Allow two tasks to synchronize their activities •Synchronization Further elaboration is done in the section „Working of Semaphore‟.
Note that. an ISR (or another task) signals the semaphore and the task is resumed.12 : Tasks synchronizing their activities. Depending on the application. more than one ISR or task could signal the occurrence of the event. When the I/O operation is complete. Using a semaphore for this type of synchronization is using what is called a unilateral rendezvous. the kernel could signal the occurrence of the event either to: a) the highest priority task waiting for the event to occur. Two tasks can synchronize their activities by using two semaphores.11 : Synchronizing tasks and ISRs If the kernel supports counting semaphores. to indicate that it is used to signal the occurrence of an event (rather than to ensure mutual exclusion. When used as a synchronization mechanism. This is called a bilateral rendezvous. the semaphore is initialized to 0. the semaphore would accumulate events that have not yet been processed. A bilateral rendezvous is similar to a unilateral rendezvous except both tasks must synchronize with one another before proceeding. Fig. or another task when no data is being exchanged. Fig. or b) the first task waiting for the event. the semaphore is drawn as a flag. Note that more than one task can be waiting for the event to occur. Working of Semaphore A task can be synchronized with an ISR. in this case. by using a semaphore as shown in Figure below . In this case. in which case it would be drawn as a key).7. A task initiates an I/O operation and then waits for the semaphore. μC/OS-II Semaphore functions Provides for using same semaphore functions as an event signaling flag or mutex or counting semaphore . as shown in Figure below.
decrement the value of semaphore and run the waiting codes To check whether semaphore value > 0 and if yes. OSSemCreate (semVal) OS_Event OSSemCreate (unsigned short semVal) OSSemPend (*eventPointer. Used when there is no need to suspend a task. semaphore value at start = 0. which means resource available and 0 will mean not available. To check whether semaphore is pending or not pending (0 or >0). which means event yet to occur and 1 will mean event occurred. OSSemPost (*eventPointer) unsigned byte OSSemPost (OS_EVENT*eventPointer) . If pending (=0). *SemErrPointer) void OSSemPend (OS_Event *eventPointer. respectively. increment. then retrieve and decrement. Increment makes the semaphore again not pending for the waiting tasks. Semaphore value at start = 1. key and count. SemVal if 0 or more. If >0. Semaphore as mutex functions When a semaphore created is used as a resource acquiring key. unsigned short timeOut. timeOut. unsigned byte *SemErrPointer) OSSemAccept (*eventPointer) • unsigned short OSSemAccept (OS_EVENT *eventPointer) To create and initialize semaphores. For event-flag. only decrease it to 0 if value is not already zero. then suspend the task till >0 (released).Semaphore for event flag functions When a semaphore created is used as a an event signaling flag or as counting semaphore.
h file.13. Simulation in Keiluvision4 & Output Fig.2: This figure shows how to define Task function. Fig. .1: This shows how to allocate priorities to tasks in main.8.13.
.B & C). Fig.13.3: In this figure we have to create our application tasks which are specified here as Task(A.13.Fig.4: As priority of Task C is higher it will execute first.
due to sempost .13. due to OSdelay().13.5: As Task A has got 2nd priority so after execution of Task C. .6: As Task b has got 3rd priority. it will jump here.Fig. Fig. so that it will jump here.
which means 6 microsec delay.8: This figure shows after execution of Task C two step.13.13. Fig.Fig. see in GPIO C window I/O Port pin 7 goes low. As in above figure 6u is defined. We can change value over there according to our application.7: This figure shows how to give delay in OS. .
.13.10: This figure shows after execution of Task B.13.5) goes low.6.Fig. due to time over of OSdelay it will again go to Task C. in figure blue arrow indicates that. now when again OSdelay comes in TaskC it will resume its position from where it had ended. in figure it is shown by yellow color arrow.5) gows down.9: This figure shows after execution of Task A all step. Fig. as shown in GPIO D I/O pin (7. see in GPIO B window I/O Port pin (7.
It was tedious doing all time the configuration settings for each new project created. Also . That‟s what shown in Manual of kit. . Troubleshooting Since the software and hardware both were new for us . Many fundamentals got cleared. After becoming familiar we are given a task to port OS in kit & perform an application on it afterwards.. size). That‟s now new challenge. Keil uv4 was helpful running our 8KB code . We gone through Rajkamal book for embedded and also uCOS-II ebook. it took much time first to become familiar with it.Cortex-M3. But 25% was also not easy. Atlast the OS got ported in kit(bingo).. when Keil comes to help us saying that I‟m with you why Eclipse? . which is not possible in Keil uv3 (2KB max. Then the tasks created and multitasking is done. We got tons of errors(!) while simulating the program in Eclipse. VAV sir helped a lot.9. 75% task is done. making an report is also not an easy task !. Now. We wandered on internet & to our CE friends to know concepts of OS & then for knowing the concepts of Semaphore. Our half of the semester(!) just gone understanding Eclipse. Then the tragedy was eliminated .
Thumb State) www.asia/cw (ARM Cortex M3 .en. References 1.pudn.wikipedia. 5.com (OS Porting information) www. www. Stellaris Guru Manual V7 Final ebook. 6. 3. Embedded System by RajKamal.com/RTOS (Information about Real Time Systems) . uCOSII_ebook Use r Guide for „Stellaris® Peripheral Driver Library. 4.. 7.dreamcatcher. 2.10.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.