User Tools

Site Tools


lab2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
lab2 [2010/02/24 18:07] natalialab2 [2014/01/21 05:07] (current) allison
Line 1: Line 1:
-==== Background Information ==== +====== Lab 2 ======
-=== μC/OS-II Overview === +
-μC/OS-II (read as MicroC/OS-II) is the second generation of μC/OS which is a priority-based, preemptive and real-time multitasking operating system written mainly in the C programming language. It is originally published in a book by Jean J. Labrosse, μC/OS The Real-Time Kernel, which purpose was to describe the internals of a portable operating system with a small footprint. It is now a product which is maintained by Micrium Inc. and licenses are issued per product or royalty free for non-commercial educational uses. Even though the source code of μC/OS is available, it is not by any means considered free or open source software.+
  
-μC/OS-II is an extremely detailed and highly readable design study which is particularly useful to the embedded systems student. While documenting the design and implementation of the kernel, the book also walks through the many related development issues such as how to adapt the kernel for a new microprocessor, how to install the kernel, and how to structure the applications that run on the kernel. 
  
-=== μC/OS-II Important Features === +==== Background ====
-Important features of μC/OS-II are ((Based on a presentation by Enric Pastor http://studies.ac.upc.edu/EPSC/SED/Apuntes/uCOSII.pdf)): +
-  * Highly portable, scalable and preemptive real-time multitasking kernel that you only build what you need. +
-  * It can manage a predefined maximum number of tasks. +
-  * It can be expanded and connected to addons such as μC/GUI and μC/FS which are GUI and File Systems for μC/OS-II +
-  * It supports all type of processors from 8-bit to 64-bit+
  
-μC/OS-II like most modern operating systems has the following components: +[[ucos background|Background Information]]
-  * Task Management (i.e. Create, Delete, Change Priority and Suspend/Resume tasks) +
-  * Time and Timer Management +
-  * Fixed Sized Memory Block management. +
-  * Inter-Task Communication (i.e. Message Mailboxes and Message Queues) +
-  * Semaphores, Mutual Exclusion Semaphores +
-  * Many external modules are available as the real-time addons to the core (μC/GUI, μC/FS, μC/CAN, μC/USB, μC/TCP-IP and many more).+
  
-μC/OS-II allows one to create new tasks and check the existing status of the tasks stack. Tasks can be deleted or their priority can be changed. Also μC/OS-II provides general information about a specific task and allows one to suspend or resume operation as well on a task. 
  
-The current version of μC/OS-II can manage up to 64 tasks. The four highest priority tasks and the four lowest priority tasks are reserved for the OS itself. The lower the value of the priority, the higher the priority of the task. The task priority number also serves as the task identifier μC/OS-II uses rate preemptive monotonic scheduling such that the highest rate of execution is given to the highest priority task which is ready. Tasks are periodic and do not synchronize with one another and  
  
-=== μC/OS-II Frequently Used Functions === 
-== OSInit == 
-OSInit function is used to initialize the internals of μC/OS-II and MUST be called prior to creating any μC/OS-II object and, prior to calling OSStart(). 
  
-== OSStart == +==== Prelab studies ==== 
-OSStart function is used to start the multitasking process which lets μC/OS-II manages the task that you have createdBefore you can call OSStart(), you MUST have called OSInit() and you MUST have created at least one task.+Please make sure to read and understand the license agreements listed below: 
 +  * {{:legalnotice_os_only.pdf}} 
 +  * {{:micrium-sla-cpu.pdf}} 
 +  * {{:micrium-sla-p1.pdf}} 
 +  * {{:micrium-sla-pl.pdf}}
  
-== OSIntEnter == 
-OSIntEnter function is used to notify μC/OS-II that you are about to service an interrupt service routine (ISR). This allows μC/OS-II to keep track of interrupt nesting and thus only perform rescheduling at the last nested ISR. You are allowed to nest interrupts up to 255 levels deep. 
  
-== OSIntExit == +Also reference the following study guides and application notes: 
-OSIntExit function is used to notify μC/OS-II that you have completed servicing an ISRWhen the last nested ISR has completed, μC/OS-II will call the scheduler to determine whether a new, high-priority task, is ready to run.+  * {{:an1004_the_10-minute_guide_to_rtos_.pdf}} 
 +  * {{:ucos-ii-refman.pdf}} 
 +  * {{:quickrefchart-color.pdf}} 
 +  * {{:task-state-diagram.pdf}} 
 +  * {{:an1002_mutual_exclusion_semaphores_.pdf}} 
 +  * {{:an1005_inter-process_communication_.pdf}} 
 +  * {{:an1007a_c_os-ii_and_event_flags_.pdf}} 
 +  * {{:ucos-ii-cfgman.pdf}} 
 +  * {{:taskassignmentworksheet.pdf}} 
 +  * {{:lcd-manual.pdf}} 
 +  * {{:whatsnewsince-v200.pdf}} 
 +  * {{:releasenotes.pdf}}
  
-You MUST invoke OSIntEnter() and OSIntExit() in pairs. In other words, for every call to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the end of the ISR. 
  
-Please note that rescheduling is prevented when the scheduler is locked (see [[syntax#OS_SchedLock|OS_SchedLock()]]) 
  
-== OSTaskCreate == +  * Make sure you fully understand the previous labs ([[lab1|Lab 1]]). 
-OSTaskCreate function is used to have μC/OS-II manage the execution of a taskTasks can either be created prior to the start of multitasking or by running task. A task cannot be created by an ISR.+  * Also read the application note 1456 which provides general information about the stationary project used in the lab: 
 +    * {{:an-1456_c_os-ii_dragon12_development_board_.pdf}}
  
-Signature: + 
-<code>INT8U OSTaskCreate (void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT8U prio)</code>+==== Prelab Evaluation ==== 
 +μC/OS-II source code is divided into platform dependent and platform independent files. Platform independent files can be found in Micrium/Software/uCOS-II/Source/. Platform independent files can be found in Micrium/Software/uCOS-II/Ports/HCS12/Paged/Metrowerks/SerialMonitor/.  
 + 
 +By studying the source structure and Micrium/ReadMe/uCOS-II-RefMan.pdf briefly answer the following questions: 
 +  What is the process of creating a new task in μC/OS-II? Provide sample pseudo code by studying the “KeypadTask” code block used in the lab. 
 +  Explain how OSFlagPend function works and how it prevents the “KeypadTask” from accessing the critical LCD resource. 
 +  Prepare a version of the demo program that guards the LCD resource using semaphores instead of OSFlag (see {{:an1005_inter-process_communication_.pdf}}) 
 + 
 + 
 +==== Procedure ==== 
 +  * Open the lab stationary using CodeWarrior located in: 
 +<code>LAB03/Micrium/Software/EvalBoards/Freescale/MC9S12DG256B/WytecDragon12/Metrowerks/Paged/OS-Probe-LCD/OS-Probe-LCD.mcp</code> 
 +  * Recompile the project and transfer the binaries to Dragon12 board as explained in [[lab1|Lab 1]]. Try the program and ensure you know how it works {{:icon3.jpg?30}} 
 +  * Do the same for the program you developed in the prelab to use semaphores to protect the critical code segments in the LCD access. Test and debug.  
 +  * Demonstrate the working program to your T.A. 
 + 
 +Submit the source code and prelab answers using the command: //submit 4352 lab2 filename// to submit your prelab report and and code. (Use “man submit” for details on how to use the submit command. The “course” is “4352”, the “assignment” is “lab2”.) 
 + 
 + 
 + 
 + 
 +==== Resources ===== 
 +  * {{:lab02.zip}} 
 +  * {{:serialmonitor.zip}}
lab2.1267034832.txt.gz · Last modified: by natalia