lab2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
lab2 [2010/02/24 23:39] – natalia | lab2 [2014/01/21 05:07] (current) – allison | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ==== Background Information | + | ====== |
- | === μC/OS-II Overview | + | |
- | μC/OS-II (read as MicroC/ | + | |
- | μ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, | ||
- | === μC/OS-II Important Features | + | ==== Background ==== |
- | Important features of μC/OS-II are ((Based on a presentation by Enric Pastor http:// | + | |
- | * 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/ | + | |
- | * 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 created. Before 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 |
+ | * {{: | ||
+ | * {{:micrium-sla-cpu.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 ISR. When the last nested ISR has completed, μC/OS-II will call the scheduler to determine whether a new, high-priority | + | * {{: |
+ | * {{:ucos-ii-refman.pdf}} | ||
+ | * {{: | ||
+ | * {{:task-state-diagram.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# | ||
- | == OSTaskCreate == | + | * Make sure you fully understand |
- | OSTaskCreate function is used to have μC/OS-II manage | + | * Also read the application note 1456 which provides |
+ | * {{:an-1456_c_os-ii_dragon12_development_board_.pdf}} | ||
- | Signature: | ||
- | < | ||
- | Arguments: | + | ==== Prelab Evaluation ==== |
- | * Task argument is a pointer to the task' | + | μC/OS-II source |
- | * P_arg argument | + | |
- | < | + | |
- | { | + | |
- | for (;;) | + | |
- | { | + | |
- | Task code; | + | |
- | } | + | |
- | } | + | |
- | </code> | + | |
- | * Ptos argument is a pointer to the task's top of stack. If the configuration constant OS_STK_GROWTH | + | By studying |
- | * Prio argument is the task's priority. A unique priority MUST be assigned to each task and the lower the number, | + | * What is the process |
+ | * Explain how OSFlagPend function works and how it prevents | ||
+ | * Prepare a version of the demo program that guards | ||
- | Returns: | ||
- | * OS_ERR_NONE: | ||
- | * OS_PRIO_EXIT: | ||
- | * OS_ERR_PRIO_INVALID: | ||
- | * OS_ERR_TASK_CREATE_ISR: | ||
- | == OSTaskDel | + | ==== Procedure ==== |
- | OSTaskDel function allows you to delete a task. The calling task can delete itself by its own priority number. The deleted task is returned | + | * Open the lab stationary using CodeWarrior located in: |
+ | < | ||
+ | * Recompile the project and transfer the binaries | ||
+ | * Do the same for the program you developed in the prelab to use semaphores | ||
+ | * Demonstrate | ||
- | Signature: | + | Submit the source |
- | <code>INT8U OSTaskDel (INT8U prio)</code> | + | |
- | Arguments: | + | |
- | * prio argument is the priority of the task to delete. Note that you can explicitely delete | + | |
- | Returns: | + | |
- | * OS_ERR_NONE: | + | |
- | * OS_ERR_TASK_DEL_IDLE: | + | |
- | * OS_ERR_PRIO_INVALID: if the priority you specify is higher that the maximum allowed (i.e.>= OS_LOWEST_PRIO) or, you have not specified OS_PRIO_SELF. | + | ==== Resources ===== |
- | * OS_ERR_TASK_DEL: if the task is assigned to a Mutex PIP. | + | * {{:lab02.zip}} |
+ | * {{:serialmonitor.zip}} |
lab2.1267054784.txt.gz · Last modified: 2010/02/24 23:39 by natalia